定制 victormgomes/laravel-modules-plus 二次开发

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

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

victormgomes/laravel-modules-plus

Composer 安装命令:

composer require victormgomes/laravel-modules-plus

包简介

Enhancements for the nWidart/laravel-modules package

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads License

The Plug-and-Play Engine for Laravel Modules.

Introduction

Laravel Modules Plus is a zero-configuration enhancement designed to transform your modules into truly self-contained, autonomous units. By extending the provided AbstractModuleServiceProvider, your modules instantly become Plug-and-Play: they automatically handle their own resource registration, factory resolution, and data seeding without any manual boilerplate in the main application.

Why use this package?

  • Module Autonomy: Modules become self-configuring "mini-packages". Drop a module into any project, and its logic is instantly alive.
  • Standardized Structure: Enforces a clean, consistent convention across all modules, making your codebase predictable and enterprise-ready.
  • Zero-Config Discovery: Automatic registration of Routes, Policies, Observers, and Events based on simple folder conventions.
  • Agnostic Factory Resolution: Automatically resolves Eloquent factories for modular models. Keep your models clean and free of package-specific traits.
  • Dynamic Seeding: Effortlessly manage data population with helpers that discover seeders across your entire modular ecosystem.
  • Full Command Integration: All original nWidart/laravel-modules commands are fully supported and aware of the Environment Control patch.
  • AI-Enhanced Development: Includes a built-in Laravel Boost Skill to help AI agents build and maintain your modules correctly.
  • Contextual Flexibility: Optionally separate resources (Migrations, Seeders) into specific contexts like Tenant or Central for complex architectures.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by sponsoring us on GitHub.

Installation

  1. Install the package via composer:
composer require victormgomes/laravel-modules-plus
  1. (Optional) Publish the configuration and stubs:
php artisan modules-plus:install
  1. Update your config/modules.php to use the new Activator:
'activator' => 'env',
'activators' => [
    'env' => [
        'class' => \Victormgomes\ModulesPlus\Activators\EnvActivator::class,
    ],
],

Usage

1. Activating Modules

Manage module activation directly via your .env file, keeping your modules_statuses.json out of version control:

APP_MODULES_ENABLED=Auth,User,Chat,Billing

All standard commands (e.g., php artisan module:list, module:migrate) will respect this setting automatically. Commands like php artisan module:enable {name} will now update your .env file directly.

2. Standard Plug-and-Play Structure

By extending AbstractModuleServiceProvider, the following resources are discovered and registered automatically (respecting any custom paths defined in your modules.php configuration):

  • Routes: routes/api.php and routes/web.php are loaded with standard middleware.
  • Config: Automatically merges {module}/config/{module}.php into the global configuration.
  • Views: Loads views from resources/views/ using the {module}:: namespace.
  • Translations: Loads lang files from resources/lang/ (including JSON).
  • Migrations: All migrations in database/migrations/ are loaded by default.
  • Factories: Factories in database/factories/ are automatically resolved for modular models.
  • Seeders: All seeders in database/seeders/ can be dynamically retrieved for seeding.
  • Policies: app/Policies/UserPolicy.php is automatically linked to app/Models/User.php.
  • Observers: app/Observers/UserObserver.php is automatically linked to app/Models/User.php.
  • Events/Listeners: Automatically discovers listeners in the app/Listeners/ directory.
  • Console Commands: Automatically registers all commands in app/Console/Commands/.
  • View Components: Registers components in app/View/Components/.
  • Livewire: Automatically registers components in the Livewire/ directory.

3. Contextual Discovery (Advanced)

For more complex architectures (like Multi-Tenancy), the package allows you to silo resources into sub-contexts:

  • Contextual Migrations: Place migrations in database/migrations/Tenant to load them only in specific database contexts.
  • Contextual Seeders: Use subfolders like database/seeders/Tenant/ and retrieve them using the SeederPaths helper:
use Victormgomes\ModulesPlus\Support\SeederPaths;
use Victormgomes\ModulesPlus\Support\TenantSeeders;

// Get seeders for any custom context
$seeders = SeederPaths::get('MyContext');

// Or use the built-in Tenant helper
$seeders = TenantSeeders::getSeeders();

$this->call($seeders);

AI Agent Integration (Laravel Boost)

This package includes a dedicated Laravel Boost Skill. When installed, it helps AI agents (like Gemini CLI, Cursor, or Claude) understand the modular architecture, respect folder conventions, and generate correct plug-and-play code.

To install the skill in your project:

php artisan boost:install

Then select victormgomes/laravel-modules-plus from the third-party skills list.

Configuration

After publishing the configuration via php artisan modules-plus:install, you can customize the following in config/modules-plus.php:

  • custom_stubs: When enabled, the package uses internal optimized stubs that follow the AbstractModuleServiceProvider pattern.
  • paths: Define additional folder conventions for resource discovery that are not present in the default nWidart/laravel-modules configuration.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

victormgomes/laravel-modules-plus 适用场景与选型建议

victormgomes/laravel-modules-plus 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 112 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「Victor M. Gomes」 「modules-plus」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 victormgomes/laravel-modules-plus 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 victormgomes/laravel-modules-plus 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-28