Files
Obsidian-Vault/Work/Random/Laravel-Modularization-Packages-and-Approach.md
2026-02-24 08:24:38 +01:00

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)

  1. Pick one vertical slice first (for example: Billing, Catalog, Orders).
  2. Move code by feature, not by layer:
    • Routes, controllers, requests, policies, views, jobs, listeners, tests.
  3. Keep a small Shared or Common area and treat it as a strict dependency boundary.
  4. Expose module behavior through clear interfaces (application services, actions, events), not direct class reach-through.
  5. Move one module at a time and run tests after each move.
  6. 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), requires illuminate/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

  1. Create branch: chore/modularization-poc.
  2. Install one candidate package.
  3. Create one real module (Billing or equivalent).
  4. Move one endpoint + one background job + one policy + one test suite into that module.
  5. Verify:
    • php artisan route:list
    • migrations load correctly
    • test suite still passes
    • no circular dependencies to/from other domains
  6. Estimate complexity before scaling to all domains.