dnt / laravel-module
v1.1
2022-03-03 19:32 UTC
Requires
- php: ^8.1
- dnt/json: dev-master
- illuminate/filesystem: v9.x
- illuminate/support: ^v9.1
Requires (Dev)
- phpunit/phpunit: v9.5
This package is auto-updated.
Last update: 2024-11-29 06:41:42 UTC
README
SETUP
composer require dnt/laravel-module
- require php >= 8.1
MODULE.JSON
- file in path:
modules/{namemodule}/module.json
- template:
{ "name": "NameModule", "key": "key-module", "providers": [ "namespace service provider" ], "aliases": { "alias": "namespace class" }, "files": [ "file path" ], "views": [ "./views" ], "langs": [ "./lang" ], "enable": true }
EXAMPLE
- Module cart manager
- Struct
|-app
|-bootstrap
|-config
...
|-modules
|----CartManager
|-------Facades
|-----------Cart.php
|-------Providers
|-----------CartManagerServiceProvider.php
|-------views
|------------index.blade.php
|-------lang
|------------en
|----------------validation.php
|------------en.json
|-------helpers.php
|-------module.json
...
|-composer.json
|.env
...
{ "name": "Cart Manager", "key": "cart-manager", "providers": [ "CartManager\\Providers\\CartManagerServiceProvider" ], "aliases": { "Cart": "CartManager\\Facades\\Cart" }, "files": [ "./helpers.php" ], "views": [ "./views" ], "langs": [ "./lang" ], "enable": true }
HELPER
- get module
app(\DNT\Module\Contracts\Management::class)->get('cart-manager');
- get all module
app(\DNT\Module\Contracts\Management::class)->all();
- enable module
app(\DNT\Module\Contracts\Management::class)->enable('cart-manager');
- disable module
app(\DNT\Module\Contracts\Management::class)->disable('cart-manager');
- get view
// Controller ... return view('cart-manager::index'); ...
- get translation
__('cart-manager::name');