zingle-com / laravel-modules
为Laravel添加模块。
1.0.0
2020-01-31 04:16 UTC
Requires
- php: ~7.0|~7.1
Requires (Dev)
- escapestudios/symfony2-coding-standard: ^3.11
- illuminate/config: ^5.5
- illuminate/container: 5.1.x|5.2.x|5.3.x|5.4.x|5.5.x
- illuminate/support: ^5.5
- php-coveralls/php-coveralls: ^2.1
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2024-08-29 04:31:32 UTC
README
为您的Laravel项目添加模块化架构的简单辅助工具。
概述
模块化架构使您的应用程序更容易理解和扩展。此包旨在以最少的努力和最大的灵活性添加对模块的支持。在此包中,“模块”对应于项目中的代码模块分组。
安装
使用composer安装基础包。
$ composer install zingle-com/laravel-modules
在Illuminate提供者之后、您的项目提供者之前,将服务提供者添加到您的提供者中。
// config.php // ... 'providers' => [ // ... Illuminate\Validation\ValidationServiceProvider::class, Illuminate\Session\SessionServiceProvider::class, Illuminate\Notifications\NotificationServiceProvider::class, /** * Vendors */ // ... ZingleCom\LaravelModules\ModuleServiceProvider::class, // ... /** * Project providers */ ],
最后,安装供应商资源
$ php artisan vendor:publish --provider="ZingleCom\LaravelModules\ModuleServiceProvider::class"
使用方法
在定义了您的模块化结构之后,要创建一个新模块,只需在对应于模块名称的基础模块目录中添加一个新的扩展Module的类。例如,如果您有一个名为Auth的模块,其基础目录为app/Modules/Auth,您将创建以下类
namespace App\Modules\Auth; use ZingleCom\LaravelModules\Module\Module; class AuthModule extends Module { }
然后,将新模块类添加到config/modules.php中的modules键下,例如
// modules.php // .. "modules" => [ App\Modules\Auth\AuthModule::class, ],