mozex / laravel-modules
Module Management For Laravel
Fund package maintenance!
mozex
Installs: 11 094
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/mozex/laravel-modules
Requires
- php: ^8.1.0
- amphp/parallel: ^2.3
- laravel/framework: ^10.34.2|^11.29.0|^12.0
- spatie/laravel-package-tools: ^1.19.0
- spatie/php-structure-discoverer: ^2.1
- spatie/regex: ^3.1
Requires (Dev)
- filament/filament: ^3.3.0
- larastan/larastan: ^2.9|^3.1.0
- laravel/pint: ^1.16.1
- livewire/livewire: ^3.4
- orchestra/testbench: ^8.21|^9.0|^10.0
- pestphp/pest: ^2.35.1|^3.0.0
- pestphp/pest-plugin-arch: ^2.7.0|^3.0.0
- pestphp/pest-plugin-type-coverage: ^2.8.2|^3.0.0
- phpstan/extension-installer: ^1.1
- rector/rector: ^1.1.0|^2.0.9
- spatie/ray: ^1.41
- dev-main
- 2.7.1
- 2.7.0
- 2.6.3
- 2.6.2
- 2.6.1
- 2.6.0
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.3
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.1
- 2.3.0
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.1
- 2.0.0
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1
- 1.0.0
- dev-dependabot/github_actions/stefanzweifel/git-auto-commit-action-7
- dev-dependabot/github_actions/actions/checkout-5
- dev-dependabot/github_actions/aglipanci/laravel-pint-action-2.6
This package is auto-updated.
Last update: 2025-11-06 15:09:15 UTC
README
Laravel Modules brings a clean, zero‑config modular structure to your Laravel app. Place your modules under the project root Modules/ directory and this package will auto‑discover and wire their assets: configs, service providers, helpers, artisan commands, migrations, translations, views, Blade components, routes (web/api/console/broadcasting), schedules, listeners/events, Livewire, Filament, Nova, and more.
Sensible conventions: namespaces, view/component aliases, and route groups are derived automatically.
Fine‑grained control: enable/disable modules, control load order, and override discovery patterns from
config/modules.php.Fast by default: built‑in caching makes discovery quick in all environments.
- Support Us
- Documentation
- Requirements
- Installation
- Quick start
- Configuration overview
- Features
- Caching
- Testing
- Changelog
- Contributing
- Security Vulnerabilities
- Credits
- License
Support us
Creating and maintaining open-source projects requires significant time and effort. Your support will help enhance the project and enable further contributions to the Laravel community.
Sponsorship can be made through the GitHub Sponsors program. Just click the "Sponsor" button at the top of this repository. Any amount is greatly appreciated, even a contribution as small as $1 can make a big difference and will go directly towards developing and improving this package.
Thank you for considering sponsoring. Your support truly makes a difference!
Documentation
Detailed documentation, including examples and best practices, lives in the docs directory.
Index
- Start here: docs/README.md
Feature guides
- Blade Components: class-based components
- Views: namespacing and anonymous components
- Routes: groups, broadcasting, console routes
- Configs: merge strategy and priority
- Migrations
- Seeders
- Commands
- Helpers
- Models & Factories
- Policies
- Events & Listeners
- Schedules
- Livewire Components
- Filament Resources/Pages/Widgets/Clusters
- Nova Resources
Requirements
- PHP: ^8.1
- Laravel: ^10.34.2 | ^11.29.0 | ^12.0
Installation
Install via Composer:
composer require mozex/laravel-modules
Publish the config file (optional, only if you want to tweak defaults):
php artisan vendor:publish --tag=laravel-modules-config
This will publish config/modules.php.
Quick start
By default, modules live under the project root Modules/ directory. Each module contains a conventional structure, for example:
project-root/
├── app/
├── bootstrap/
├── config/
├── database/
├── Modules/
│ ├── Blog/
│ │ ├── Config/
│ │ ├── Console/
│ │ ├── Database/
│ │ │ ├── Factories/
│ │ │ ├── Migrations/
│ │ │ └── Seeders/
│ │ ├── Filament/
│ │ ├── Lang/
│ │ ├── Listeners/
│ │ ├── Models/
│ │ ├── Policies/
│ │ ├── Providers/
│ │ ├── Resources/
│ │ │ └── views/
│ │ ├── Routes/
│ │ └── View/
│ │ └── Components/
│ └── Shop/
│ └── ...
└── vendor/
Out of the box, the package will automatically discover and register the following assets inside your modules: configs, service providers, helpers, artisan commands, migrations, translations, views, Blade components, models, factories, policies, routes, schedules, listeners/events, Livewire, Filament, and Nova resources.
Use your assets via namespaced conventions:
- Views:
view('blog::post.show')maps toModules/Blog/Resources/views/post/show.blade.php - Class-based Blade components:
<x-blog::post.card/>forModules/Blog/View/Components/Post/Card.php - Anonymous Blade components (from views):
<x-blog::button.primary/>forModules/Blog/Resources/views/components/button/primary.blade.php - Routes: drop files under
Modules/*/Routes/*.phpand they will be loaded under sensible groups (web, api). See the Routes feature docs for customization.
Note for contributors: the test workbench lives in workbench/ and follows the same conventions (workbench/Modules/*).
Configuration overview
All options live in config/modules.php.
- modules_directory: default
Modules(relative to the project base path). Change where your modules are stored. - modules_namespace: default
Modules\\. Change the PSR-4 base namespace for your modules. - modules: per-module activation and ordering. Example:
'modules' => [ 'Shared' => [ 'active' => true, 'order' => 1, // lower loads earlier ], ],
- Per-asset sections: each feature can be enabled/disabled and configured with glob patterns and other options. For example, Blade Components:
'blade-components' => [ 'active' => true, 'patterns' => [ '*/View/Components', ], ],
- Configs merging priority: when
'configs.priority' => true, values from your modules override the app config; when false, app config wins and modules provide defaults.
You can disable any feature by setting 'active' => false in its section.
Features
This package discovers and wires many module assets. We’ll document them in depth, one by one. Suggested reading order:
- Blade Components (class-based)
- Views (namespaces, anonymous components)
- Routes (groups, api/web, broadcasting, commands)
- Configs (merging strategy, priority)
- Migrations
- Seeders
- Commands
- Helpers
- Models & Factories
- Policies
- Events & Listeners
- Schedules
- Livewire Components
- Filament (Resources, Pages, Widgets, Clusters)
- Nova Resources
Caching
This package supports a single discovery cache that speeds up scanning your Modules directory. Use these commands:
- Build the discovery cache:
php artisan modules:cache
- Clear the discovery cache:
php artisan modules:clear
Tip: after adding, renaming, or moving module assets, clear any relevant Laravel caches and rebuild the modules discovery cache as needed.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.