有没有办法在 Laravel 中创建子模块?
Is there a way to create submodules in Laravel?
我正在用 laravel 开发一个网站,我正在使用模块,但我想知道我是否可以让这些模块有子模块
像
laravel-app/
app/
bootstrap/
vendor/
modules/
├── Admin/
├── 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
|──modules
|──AdminConfig
├── 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
我通过更改 config/module.php 中的文件做到了这一点,但 运行 php artisan serve
Laravel 的文档提供了一些关于 directory structure.
的信息
The majority of your application is housed in the app directory. By default, this directory is namespaced under App and is autoloaded by Composer using the PSR-4 autoloading standard.
换句话说,只要您遵循PSR-4,您就可以按照自己的意愿构建应用程序。因此,我会将您的模块放入具有适当 PSR-4 命名空间的应用程序目录中。
示例:
namespace App\Module1\Services;
namespace App\Module2\Services;
namespace App\Services; //For common services
但是,在我的应用程序中,我更喜欢在现有目录中创建 "module"。
示例:
namespace App\Services\Module1;
namespace App\Services\Module2;
namespace App\Services; //For common services
我正在用 laravel 开发一个网站,我正在使用模块,但我想知道我是否可以让这些模块有子模块 像
laravel-app/
app/
bootstrap/
vendor/
modules/
├── Admin/
├── 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
|──modules
|──AdminConfig
├── 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
我通过更改 config/module.php 中的文件做到了这一点,但 运行 php artisan serve
Laravel 的文档提供了一些关于 directory structure.
的信息The majority of your application is housed in the app directory. By default, this directory is namespaced under App and is autoloaded by Composer using the PSR-4 autoloading standard.
换句话说,只要您遵循PSR-4,您就可以按照自己的意愿构建应用程序。因此,我会将您的模块放入具有适当 PSR-4 命名空间的应用程序目录中。
示例:
namespace App\Module1\Services;
namespace App\Module2\Services;
namespace App\Services; //For common services
但是,在我的应用程序中,我更喜欢在现有目录中创建 "module"。
示例:
namespace App\Services\Module1;
namespace App\Services\Module2;
namespace App\Services; //For common services