itvisionsy/laravel-modules
Composer 安装命令:
composer require itvisionsy/laravel-modules
包简介
Laravel 5.1 library to allow modules structure. Each module can have its routes, controllers, views, config, ...
README 文档
README
Modules management library for laravel 5.1
Allows modules structure of your project. Each module can have its views, config, routes, controllers, ...
Installation
- The package relies on the composer PSR-4 loader like all laravel projects. Use the composer command:
composer require itvisionsy/laravel-modules - Add
\ItvisionSy\Laravel\Modules\ServiceProvider::classto providers section in yourconfig/app.phpfile:'providers'=>[ //... \ItvisionSy\Laravel\Modules\ServiceProvider::class, ],
- Publish the config file using the command
This will copy thephp artisan vendor:publishmodules.phpconfig file to yourconfigfolder. - Modify the
config/modules.phpconfig file as needed.
How It Works
Your modules should go in a root modules folder. By default this is app/Modules which maps to the namespace
\App\Modules.
Each of your modules will have its own folder inside the modules root folder, the folder will be named after the module
name, and will map to the namespace \App\Modules\{ModuleName}.
Each module will contain a base module definition class, which (by default) will be named Module.php and maps to
the namespace \App\Modules\{ModuleName}\Module. This class will act as the key generator for the module URLs, routes,
and other framework-related values.
Each module will contain its data models, controllers, views, routes, and other project files as usual. The composer
PSR-4 loader should take care of loading your module files and classes properly.
Your module controllers (by default go into the Http/Controllers folder) should inherite the
ItvisionSy\Laravel\Modules\Controller class to make views rendering and other tasks easier.
Creating Modules
To create a new module, you can use the artisan command
php artisan modules:make {id} [{name}] [--url={url}]
Values of id, name, and url are strings. The name and URL parts are optional. URL will be used to generate the
URLs of the module more human friendly. Name is used for human identification and readability only.
This command will create the basic folder structure inside the modules folder, along with the base module and a sample
routes (inside Http/routes.php), controller (inside Http/Controllers/), and view (inside Views).
As you have the basic structure, you can start creating your files and classes as normal. Nothing special to worry about.
What is Store Handler
It is a feature allows a per-module configuration to be saved in the database, in addition to a flag to identify if a module is enabled or disabled.
You need a class that implements the ItvisionSy\Laravel\Modules\Interfaces\KeyValueStoreInterface interface, which
defines two methods: set($key, $value) and get($key, $default=null).
There are two ready-made implementations in the \ItvisionSy\Laravel\Modules\StoreHandlers\ namespace, one is calle
MysqlSimpleDbStoreHandler and the other SqliteSimpleDbStoreHandler, which utilizes a DB connection (default one
by default) to store the config in a simple key/value table.
The feature comes disabled by default by setting the class \ItvisionSy\Laravel\Modules\StoreHandlers\DummyStoreHandler
as the store handler. To enable it, just change the store_handler config setting in the config/modules.php config
file to use one of the two classes mentioned above.
//config/modules.php config file 'store_handler' => \ItvisionSy\Laravel\Modules\StoreHandlers\SqliteSimpleDbStoreHandler::class,
Also, you need to create the database table for the store. We provided a simple artisan command to do that. After you
have configured everything correctly, simply execute the following command:
php artisan modules:db:init
which will take care about creating the database table by executing the following SQL command:
CREATE TABLE IF NOT EXISTS `modules_storage` ( `key` VARCHAR(200) UNIQUE NOT NULL PRIMARY KEY, `value` VARCHAR(200) NULL );
You can create the table manually, and override its name by extending the class and change the $tableName property.
Thanks
- JetBrains for the free license of PHPStorm IDE. The great tool I wrote this module with.
itvisionsy/laravel-modules 适用场景与选型建议
itvisionsy/laravel-modules 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 26 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 03 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「modules」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 itvisionsy/laravel-modules 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 itvisionsy/laravel-modules 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 itvisionsy/laravel-modules 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This is Paymorrow module for OXID eShop.
Analysis module for finding problematical shop data.
yii2 swiper slider
An interactive tour through the TYPO3 backend.
Modular Backend Code Generation Engine for laravel 9.2, Vue.js 3.x and Tailwindcss 3.x inspired. Inspired by nwidart/laravel-modules and savannabits/jetstream-inertia-generator
Alfabank REST API integration
统计信息
- 总下载量: 26
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-14