Looking to hire Laravel developers? Try LaraJobs

laravel-modules-plus maintained by victormgomes

Description
Advanced infrastructure and zero-config resource discovery addon for nwidart/laravel-modules
Last update
2026/04/28 10:00 (dev-main)
License
Downloads
0

Comments
comments powered by Disqus

Laravel Modules Plus

Latest Version on Packagist Total Downloads License

Advanced infrastructure and zero-config resource discovery addon for nwidart/laravel-modules.


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.

Key Features

  • .env Based Activation: Control enabled modules directly via your environment file (APP_MODULES_ENABLED). No more tracking modules_statuses.json in version control.
  • Abstract Base Provider: Automatically discovers and registers:
    • Routes: API, Web, Console, and Broadcast Channels.
    • Auto-Discovery: Policies, Observers, and Events based on folder naming conventions.
    • Components: Blade and Livewire components registered automatically.
    • Resources: Zero-config loading of Views and Translations.
  • Smart Multi-Tenancy Migrations: Intelligent separation of Central vs. Tenant migrations.
  • Modern Autoloading: Built-in stubs optimized for wikimedia/composer-merge-plugin.
  • Portable Stubs: Includes internal optimized stubs that ensure architectural consistency without manual setup.

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

Modules are managed via your .env file. Only modules listed here will be booted:

APP_MODULES_ENABLED=Auth,User,Chat,Billing

You can also use standard commands which will automatically update your .env:

php artisan module:enable Chat

2. Creating New Modules

When you create a module, it will automatically use the optimized stubs (if published or if custom_stubs is enabled in config).

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/ -> UserPolicy automatically linked to Models/User.
  • Observers/ -> UserObserver automatically linked to Models/User.
  • Listeners/ -> Events discovered via DiscoverEvents.
  • Database/Migrations/Tenant -> Automatically loaded only for tenant database contexts.

3. Modern Autoloading

To keep modules decoupled, this package assumes each module has its own composer.json. After creating a new module, simply run:

composer dump-autoload

Testing

composer test

Credits

License

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