I am developing modular project in laravel 5.1 using pingpong package.Which gives me the project structure as below
laravel-app/
app/
bootstrap/
vendor/
modules/
├── Blog/
├── Assets/
├── Config/
├── Console/
├── Database/
├── Migrations/
├── Seeders/
├── Entities/
├── Http/
├── Controllers/
├── Middleware/
├── Requests/
├── routes.php
├── Providers/
├── BlogServiceProvider.php
├── Resources/
├── lang/
├── views/
├── Repositories/
├── Tests/
├── composer.json
├── module.json
├── start.php
I want to separate this modules folders in "admin" and "client" for differentiate my client and admin side like below,
laravel-app/
app/
bootstrap/
vendor/
modules/
├── Admin/
├── Blog/
├── Assets/
├── Config/
├── Console/
├── Database/
├── Migrations/
├── Seeders/
├── Entities/
├── Http/
├── Controllers/
├── Middleware/
├── Requests/
├── routes.php
├── Providers/
├── BlogServiceProvider.php
├── Resources/
├── lang/
├── views/
├── Repositories/
├── Tests/
├── composer.json
├── module.json
├── start.php
├── Client/
├── Blog/
├── Assets/
├── Config/
├── Console/
├── Database/
├── Migrations/
├── Seeders/
├── Entities/
├── Http/
├── Controllers/
├── Middleware/
├── Requests/
├── routes.php
├── Providers/
├── BlogServiceProvider.php
├── Resources/
├── lang/
├── views/
├── Repositories/
├── Tests/
├── composer.json
├── module.json
├── start.php
please help me out for this, Thanks.
UPDATE:
You can mostly achieve what you are looking for by adjusting the config/modules.php
file, but you will have to switch it back and forth when switching between Admin
and Client
.
For example:
To generate (module:make
) or use (module:use
) modules within the Admin
portion of your project, you will need to do the following:
In the config/modules.php
file, adjust the namespace
to
/*
|--------------------------------------------------------------------------
| Module Namespace
|--------------------------------------------------------------------------
|
| Default module namespace.
|
*/
'namespace' => 'Modules\Admin',
In the same file, adjust the base_path
to
/*
|--------------------------------------------------------------------------
| Modules path
|--------------------------------------------------------------------------
|
| This path used for save the generated module. This path also will added
| automatically to list of scanned folders.
|
*/
'modules' => base_path('modules/admin'),
That is all you need to do and calling php artisan module:make blog
will create a Blog module within modules/admin
.
If you need to switch between the Admin
and the Client
portion of your project, you will need to adjust the same two lines within the config/modules.php
file to reflect as such.
There is one more caveat:
If you are planning to use the Assets
folder within your modules, you will need to also adjust the corresponding line within the config/modules.php
file, AND you will need to manually adjust a couple of methods with file paths explicitly written within your module's service provider (ex: Admin/Blog/Providers/BlogServiceProvider.php
), AND you will need to fix your config/view.php
- just follow the comments.
P.S. you can probably create a custom command to automate switching between Admin
and Client
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With