Download the PHP package selimppc/laravel-modules without Composer
On this page you can find all versions of the php package selimppc/laravel-modules. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download selimppc/laravel-modules
More information about selimppc/laravel-modules
Files in selimppc/laravel-modules
Package laravel-modules
Short Description Lightweight, convention-based modules for Laravel 11/12. Zero request-time overhead. Keeps app migrations by default.
License MIT
Homepage https://github.com/selimppc/laravel-modules
Informations about the package laravel-modules
Laravel Modules (lightweight)
selimppc/laravel-modules — convention-based modular structure for Laravel 11/12:
- Modules live under
/Modules/<Name> - Keep app migrations in
/database/migrations - One auto-discovered provider wires routes/views/translations
- Zero request-time overhead after
route:cache
Requirements
PHP 8.3+
Laravel 11 / 12
Install
This will:
- Create /Modules (if missing)
- Publish config/laravel-modules.php
- Publish stubs under /stubs/laravel-modules/module
- Scaffold an Example module and enable it (when using --with-example) ✅ Laravel 12: No need to edit bootstrap/app.php. The service provider is auto-discovered.
Enable modules
Edit in config/laravel-modules.php:
Autoload mapping (host app)
Add PSR-4 for your app (not the package) so Composer can load Modules\… classes:
Rebuild autoload files:
Try it
Start the dev server and visit the example routes:
Web → http://localhost:8000/example
API → http://localhost:8000/api/example
Make a new module
Enable it in config/laravel-modules.php:
Your module structure (convention):
| Migrations remain in the host app’s /database/migrations.
Production (performance)
Cache everything:
Why this is fast:
- Routes are skipped entirely at runtime when cached
- Views/translations are lazy; Blade can be precompiled with view:cache
- No directory scans on requests (uses your config list)
Troubleshooting
Target class does not exist (e.g., Modules\Example\Http\Controllers\…)
- Ensure PSR-4 mapping exists in your app’s composer.json (not dev):
"autoload": { "psr-4": { "Modules\\": "Modules/" } }
Then:
-
Check namespace & casing match the path exactly (case-sensitive FS):
- Modules/Example/Http/Controllers/ExampleController.php
- namespace Modules\Example\Http\Controllers;
- Clear route/config caches:
Verify:
Customization
-
Disable route autoloading and wire routes yourself:
-
Change module base path (e.g., to
src/Modules): - Update PSR-4 accordingly:
FAQ
Q: Can I keep using my global routes and just use modules for controllers/views?
A: Yes. Set 'autoload_routes' => false and require your module route files manually or define routes in the app.
Q: Where do I put models?
A: Inside each module (e.g., Modules/Blog/Models/Post.php) or in your app—your choice. The package is unopinionated here.
Q: Can I use repositories/services?
A: Yes. Add contracts/implementations under Repositories/... and wire them in bindings.php.
Contributing
PRs welcome! Please include tests and update the README when changing behavior. License
MIT © selimppc
All versions of laravel-modules with dependencies
illuminate/support Version ^11.0 || ^12.0
illuminate/routing Version ^11.0 || ^12.0
illuminate/console Version ^11.0 || ^12.0