nwidart/laravel-modules
Modularize large Laravel apps with nwidart/laravel-modules. Create self-contained modules (controllers, models, views, routes, config) with Artisan generators, module discovery, enabling/disabling, and per-module resources—tested and maintained across modern Laravel versions.
Auth, Payments, Inventory), improving maintainability and scalability. Aligns with the "microservices-lite" pattern for monolithic apps.module:enable/disable commands or database-backed activators (v6+). Critical for canary releases or A/B testing.CRM module alongside new Ecommerce features.module:make:controller, module:make:model) with consistent stubs and type hints, reducing boilerplate.Saas/Tenant1/Features) by combining with packages like stancl/tenancy.Adopt if:
Marketing module during holidays).Look elsewhere if:
Problem: "Our Laravel monolith is a ‘big ball of mud’—slow releases, high merge conflicts, and teams stepping on each other’s code. Tech debt is growing, and new features take 3x longer to ship."
Solution: "Laravel Modules lets us decompose the app into self-contained features (e.g., Auth, Payments) that teams can own, test, and deploy independently. Think ‘microservices for monoliths’—with 30% faster releases and 50% less merge hell."
ROI:
module:disable Payments).Ask: "Approve a 2-week spike to prototype modules for our top 3 features (Auth, Billing, Analytics). If successful, we’ll roll it out to the full team."
Why This Package?
Standardized Module Structure:
ModuleServiceProvider, routes/web.php, migrations, and stubs via module:make.php artisan module:make Auth --controller --migration --resource
Modules/Auth/ with:
Http/Controllers/AuthController.phpDatabase/Migrations/...Resources/views/auth/...Routes/web.php (isolated routes).Dynamic Enablement:
php artisan module:disable Marketing # Turn off during Q4
php artisan module:enable Analytics # A/B test new features
// config/modules.php
'activator' => \Nwidart\Modules\DatabaseActivator::class,
Asset Isolation:
// Modules/Auth/resources/js/auth.js
import './auth.js'; // Compiled separately
Tooling for Scale:
| Command | Use Case |
|---|---|
module:make:controller |
Generate controllers with --api/ --web flags. |
module:make:model |
Includes --factory/ --migration. |
module:seed |
Seed data per-module. |
module:update |
Sync all modules to latest stubs. |
Migration Path:
Risks & Mitigations:
| Risk | Mitigation |
|---|---|
| Learning curve for modules. | 1-day workshop + cheat sheet. |
| Route conflicts. | Module-specific RouteServiceProvider. |
| Asset compilation slowdown. | Parallelize Vite builds per-module. |
Next Steps:
Auth module in 2 days (proof of concept).module:make commands and activation workflows.Alternatives Considered:
How can I help you explore Laravel packages today?