定制 itvisionsy/laravel-modules 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Packagist license Build Status PHP Laravel

Allows modules structure of your project. Each module can have its views, config, routes, controllers, ...

Installation

  1. The package relies on the composer PSR-4 loader like all laravel projects. Use the composer command:
    composer require itvisionsy/laravel-modules
    
  2. Add \ItvisionSy\Laravel\Modules\ServiceProvider::class to providers section in your config/app.php file:
    'providers'=>[
       //...
       \ItvisionSy\Laravel\Modules\ServiceProvider::class,
    ],
  3. Publish the config file using the command
    php artisan vendor:publish
    
    This will copy the modules.php config file to your config folder.
  4. Modify the config/modules.php config 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

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 itvisionsy/laravel-modules 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 26
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: HTML

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-14