nwidart/laravel-modules

Split large Laravel applications into self-contained, independently generated modules — each with its own routes, controllers, views, and migrations.

Framework
Composer
vv13.0.0
6,193stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
61/100Good
Development Activity12
Maintenance44
Community88
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
69/100Good
Architecture78
Code Quality72
Innovation65
Learning Curve60

laravel-modules restructures how a Laravel application is organized by letting you break it into modules — self-contained mini-applications, each with their own controllers, models, views, routes, migrations, and service provider, generated via Artisan commands (module:make, module:make-controller, module:make-migration, and dozens more). It registers a ModulesServiceProvider that autoloads and boots every module, wires up module-scoped routing, and supports enabling/disabling individual modules at runtime through pluggable Activators. Because it changes the fundamental application structure (where code lives, how it’s discovered and bootstrapped) rather than being an imported utility, it functions as an architectural layer on top of Laravel rather than a standalone library — the successor to the unmaintained pingpong/modules package, now supported through Laravel 13.

What You Get

  • A module:make Artisan command family that scaffolds new modules with controllers, models, migrations, views, seeders, requests, and more via dedicated generators
  • ModulesServiceProvider/LaravelModulesServiceProvider that auto-discovers, autoloads, and boots every module’s own service provider and routes
  • Module-scoped routing so each module defines its own routes/web.php/api.php without colliding with the main app’s route files
  • Pluggable Activators (file-based or database-based) for enabling/disabling individual modules at runtime without removing their code
  • First-class support for both Laravel and Lumen applications, plus a ModuleManifest cache for fast module discovery in production

Common Use Cases

  • Breaking a large, monolithic Laravel codebase into feature-scoped modules that teams can own and develop independently
  • Building a modular SaaS or CMS product where optional features (billing, reporting, integrations) ship as toggleable modules
  • Sharing reusable modules across multiple Laravel projects by copying a self-contained module directory rather than extracting a full Composer package
  • Enforcing architectural boundaries in domain-driven Laravel applications by giving each bounded context its own module

Under The Hood

Architecture - The package centers on Module.php and FileRepository.php, which discover module directories (each containing a module.json manifest, parsed by Json.php), and ModulesServiceProvider, which iterates discovered modules and registers each one’s own service provider, config, translations, views, and routes at boot time; ModuleManifest.php caches this discovery for production performance the same way Laravel caches its package manifest. Module scaffolding is handled by a Generators/ subsystem invoked from Commands/, and module enable/disable state is abstracted behind an Activators/ interface so it can be backed by a flat file or a database table. Tech Stack - PHP 8.3+, built against Laravel 13 (with historical support back to Laravel 5.4 tracked via version table in the README) and Lumen, depending on wikimedia/composer-merge-plugin to merge each module’s own composer.json autoload rules into the main application; dev tooling includes PHPUnit, Orchestra Testbench (for package-in-Laravel testing), PHPStan, and Laravel Pint. Code Quality - The project maintains an explicit Laravel-version compatibility matrix across 13 major releases, uses Testbench to run its test suite inside a real Laravel application context (closer to integration testing than pure unit tests), and enforces static analysis via PHPStan and style via Pint/php-cs-fixer; with 151 contributors and continuous releases through Laravel 13, it has weathered many major-version framework migrations. API Design - The command surface mirrors Laravel’s own make:* Artisan commands (module:make-controller, module:make-migration, etc.), so developers already fluent in Laravel conventions can pick it up with minimal new vocabulary; the tradeoff is an added layer of indirection — module-scoped autoloading, routing, and views require understanding the package’s manifest/discovery model on top of vanilla Laravel’s own conventions.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search