From 069ea54dbd505c7013703065efe85f267d2cfa17 Mon Sep 17 00:00:00 2001 From: Vincent Verbruggen Date: Tue, 24 Feb 2026 08:24:38 +0100 Subject: [PATCH] vault backup: 2026-02-24 08:24:38 --- ...el-Modularization-Packages-and-Approach.md | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Work/Random/Laravel-Modularization-Packages-and-Approach.md diff --git a/Work/Random/Laravel-Modularization-Packages-and-Approach.md b/Work/Random/Laravel-Modularization-Packages-and-Approach.md new file mode 100644 index 0000000..1723b65 --- /dev/null +++ b/Work/Random/Laravel-Modularization-Packages-and-Approach.md @@ -0,0 +1,59 @@ +# 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`](https://packagist.org/packages/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`](https://packagist.org/packages/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 | Uses Composer path repositories + package discovery; lightweight and clean if you do not need runtime enable/disable modules. | +| [`zonneplan/laravel-module-loader`](https://packagist.org/packages/zonneplan/laravel-module-loader) | v6.0.2 (2025-12-15), ~116k downloads | `illuminate/* ^11||^12`, PHP ^8.2 | Minimal module loader | Lightweight loader pattern, fewer ecosystem integrations than `nwidart`. | +| [`coolsam/modules`](https://packagist.org/packages/coolsam/modules) | v5.1.0 (2026-01-26), ~87k downloads | Depends on `nwidart ^11|^12`, `filament/filament ^4|^5`, PHP ^8.3 | Filament-heavy modular apps | Wrapper to make module-first Filament workflows easier. | +| [`spatie/laravel-package-tools`](https://packagist.org/packages/spatie/laravel-package-tools) | 1.93.0 (2026-02-21), ~119M downloads | `illuminate/contracts ^10|^11|^12|^13`, PHP ^8.1 | Internal package strategy | Not a module system itself; great when each module becomes an internal Composer package. | + +## Probably avoid for Laravel 12+ + +- [`caffeinated/modules`](https://packagist.org/packages/caffeinated/modules): latest stable v6.3.1 (2021-03-26), requires `illuminate/support ^6|^7|^8`. +- [`pingpong/modules`](https://packagist.org/packages/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. + +## Reference links + +- `nwidart/laravel-modules`: https://github.com/nWidart/laravel-modules +- `nwidart` docs: https://laravelmodules.com/docs/12 +- `internachi/modular`: https://github.com/InterNACHI/modular +- `zonneplan/laravel-module-loader`: https://github.com/zonneplan/laravel-module-loader +- `coolsam/modules`: https://github.com/savannabits/filament-modules +- `spatie/laravel-package-tools`: https://github.com/spatie/laravel-package-tools +- Packagist search (Laravel modules): https://packagist.org/search/?q=laravel%20modules