4.1 KiB
4.1 KiB
Laravel Modularization: Packages and Approach
Snapshot date: 2026-02-24 Scope: Splitting a Laravel application into modules inside one codebase (modular monolith), not microservices.
Practical approach (incremental, low risk)
- Pick one vertical slice first (for example:
Billing,Catalog,Orders). - Move code by feature, not by layer:
- Routes, controllers, requests, policies, views, jobs, listeners, tests.
- Keep a small
SharedorCommonarea and treat it as a strict dependency boundary. - Expose module behavior through clear interfaces (application services, actions, events), not direct class reach-through.
- Move one module at a time and run tests after each move.
- Only after 2 to 3 successful modules, standardize scaffolding and conventions.
Package shortlist
| Package | Current signal | Compatibility signal | Best fit | Notes |
|---|---|---|---|---|
nwidart/laravel-modules |
v12.0.4 (2025-06-29), ~14.1M downloads, 6.1k favorites | README maps Laravel 12 -> package 12.x; PHP >=8.2 | Default choice for most teams | Most adopted option; strong ecosystem; uses wikimedia/composer-merge-plugin for module autoload merge. |
internachi/modular |
3.0.1 (2026-02-06), ~606k downloads, 1.1k favorites | `illuminate/support ^11 | ^12`, PHP >=8.3 | Laravel-convention-first modular monolith |
zonneplan/laravel-module-loader |
v6.0.2 (2025-12-15), ~116k downloads | `illuminate/* ^11 | ^12`, PHP ^8.2 | |
coolsam/modules |
v5.1.0 (2026-01-26), ~87k downloads | Depends on `nwidart ^11 | ^12, filament/filament ^4 |
^5`, PHP ^8.3 |
spatie/laravel-package-tools |
1.93.0 (2026-02-21), ~119M downloads | `illuminate/contracts ^10 | ^11 | ^12 |
Probably avoid for Laravel 12+
caffeinated/modules: latest stable v6.3.1 (2021-03-26), requiresilluminate/support ^6|^7|^8.pingpong/modules: legacy ancestor, last meaningful activity is old and Laravel constraints are outdated.
Recommendation by scenario
- If you want the safest default: use
nwidart/laravel-modules. - If you prefer strict Laravel package conventions and you are on PHP 8.3+: use
internachi/modular. - If Filament is central: use
nwidart/laravel-modules+coolsam/modules. - If long-term extraction into reusable packages is expected: combine your module approach with
spatie/laravel-package-tools.
Quick proof-of-concept plan
- Create branch:
chore/modularization-poc. - Install one candidate package.
- Create one real module (
Billingor equivalent). - Move one endpoint + one background job + one policy + one test suite into that module.
- Verify:
php artisan route:list- migrations load correctly
- test suite still passes
- no circular dependencies to/from other domains
- Estimate complexity before scaling to all domains.
Reference links
nwidart/laravel-modules: https://github.com/nWidart/laravel-modulesnwidartdocs: https://laravelmodules.com/docs/12internachi/modular: https://github.com/InterNACHI/modularzonneplan/laravel-module-loader: https://github.com/zonneplan/laravel-module-loadercoolsam/modules: https://github.com/savannabits/filament-modulesspatie/laravel-package-tools: https://github.com/spatie/laravel-package-tools- Packagist search (Laravel modules): https://packagist.org/search/?q=laravel%20modules