victormgomes / laravel-modules-plus
Enhancements for the nWidart/laravel-modules package
Package info
github.com/VictorMGomes/laravel-modules-plus
pkg:composer/victormgomes/laravel-modules-plus
Fund package maintenance!
Requires
- php: ^8.4
- illuminate/auth: ^11.0||^12.0||^13.0
- illuminate/console: ^11.0||^12.0||^13.0
- illuminate/contracts: ^11.0||^12.0||^13.0
- illuminate/database: ^11.0||^12.0||^13.0
- illuminate/events: ^11.0||^12.0||^13.0
- illuminate/filesystem: ^11.0||^12.0||^13.0
- illuminate/http: ^11.0||^12.0||^13.0
- illuminate/support: ^11.0||^12.0||^13.0
- illuminate/view: ^11.0||^12.0||^13.0
- nwidart/laravel-modules: ^13.0
- spatie/laravel-package-tools: ^1.16
- symfony/finder: ^7.0|^8.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- spatie/laravel-ray: ^1.35
README
Enhancements for the nWidart/laravel-modules package
Introduction
Laravel Modules Plus is a powerful, zero-configuration addon designed to transform your modules into truly self-contained, portable packages. It automates the "heavy lifting" of resource registration and provides robust environment-level control, ensuring your modular architecture is enterprise-ready.
Why use this package?
- Zero-Config Discovery: Automatically discovers and registers routes, policies, observers, and events based on simple folder conventions.
- Environment Control: Manage module activation via
.env(APP_MODULES_ENABLED), eliminating the need to trackmodules_statuses.jsonin version control. - Multi-Tenancy Ready: Intelligent separation of Central and Tenant migrations for complex application architectures.
- Portability: Optimized stubs ensure that every new module follows a consistent, decoupled structure from day one.
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
- Install the package via composer:
composer require victormgomes/laravel-modules-plus
- (Optional) Publish the configuration and stubs:
php artisan modules-plus:install
- Update your
config/modules.phpto use the new Activator:
'activator' => 'env', 'activators' => [ 'env' => [ 'class' => \Victormgomes\ModulesPlus\Activators\EnvActivator::class, ], ],
Usage
1. Activating Modules
Modules are managed via your .env file. Only modules listed here will be booted:
APP_MODULES_ENABLED=Auth,User,Chat,Billing
2. Creating New Modules
The generated Service Provider will extend AbstractModuleServiceProvider. This parent class handles all registration automatically as long as you follow the standard folder structure:
Routes/api.php,Routes/web.php-> Loaded automatically.Policies/->UserPolicyautomatically linked toModels/User.Observers/->UserObserverautomatically linked toModels/User.Database/Migrations/Tenant-> Automatically loaded only for tenant database contexts.
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.