Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Modules

Laravel Modules Laravel Package

nwidart/laravel-modules

Laravel package for structuring large apps into self-contained modules (like mini packages) with their own controllers, models, views, routes, and config. Includes Artisan generators, module discovery, and configuration for organizing and scaling projects.

View on GitHub
Deep Wiki
Context7

nwidart/laravel-modules helps you structure large Laravel applications as modules—self-contained units that behave like mini packages with their own controllers, models, views, routes, and more. It’s actively maintained and supports modern Laravel versions (tested with Laravel 11), making modular architecture practical without leaving the Laravel ecosystem.

Use it to split a monolith into clear, reusable boundaries while keeping familiar tooling and conventions.

  • Generate and manage modules via Artisan commands
  • Isolate features with module-specific routes, views, config, and migrations
  • Optional config publishing and automatic package discovery
  • Composer-friendly module autoloading (via merge-plugin)
  • Built-in test coverage compared to the original pingpong/modules project
Frequently asked questions about Laravel Modules
How do I split a large Laravel app into modules without breaking existing functionality?
Use `php artisan module:make` to create modules (e.g., `AuthModule`, `BillingModule`) with their own controllers, models, and routes. Existing routes in `app/Http/` won’t conflict if you prefix module routes (e.g., `/auth/*`) or use middleware. Modules auto-register via the service provider, so no manual bootstrapping is needed.
Can I use Laravel 11’s new features (e.g., app models, routes) inside modules?
Yes. Modules fully support Laravel 11’s conventions, including app models (place them in `Modules/{Module}/App/Models/`) and route caching. The package aligns with Laravel’s latest architecture, so you’ll get all native features like optimized route loading and model binding.
Do modules support Vite/Laravel Mix for asset compilation?
Absolutely. Modules can have isolated Vite/Laravel Mix builds by defining module-specific entry points (e.g., `resources/js/modules/Auth.js`). Configure Vite to split builds by module or use shared builds with dynamic imports. The package doesn’t enforce a specific approach, giving you flexibility.
How do I test a single module in isolation?
Disable other modules during testing with `Module::disable('OtherModule')` or use PHPUnit’s `--filter` flag to run only module-specific tests. For database-backed activation, mock the `Module` facade or use `module:disable` in your test setup. Modules can also be tested as standalone packages with `composer require` in a test project.
What’s the performance impact of using modules vs. a monolith?
Minimal. Modules lazy-load, so there’s no runtime penalty. The only overhead is during `composer dump-autoload` (~50ms), which is negligible. Database-backed activation adds a single query per request, but file-based activation is zero-cost. Benchmark your specific use case, but most teams see no meaningful slowdown.
Can I deploy modules independently (e.g., zero-downtime updates)?
Yes, but requires database-backed activation (run `php artisan module:v6:migrate`) and feature flags. Enable/disable modules via the database or storage, then update code in stages. For shared databases, use transactions or sagas to manage cross-module consistency. Avoid this for modules with tight coupling.
How do I share a model between modules (e.g., `User` in both `AuthModule` and `BillingModule`)?
Place shared models in `app/Models/` (Laravel 11) or use a shared module (e.g., `CoreModule`). Avoid duplicating models in multiple modules. For module-specific logic, extend the shared model or use traits. The package doesn’t restrict model placement, so follow Laravel’s conventions for shared resources.
What’s the difference between file-based and database-backed module activation?
File-based activation uses `storage/framework/modules.php` (zero-config, default) and is ideal for simple apps. Database-backed activation (via `module:v6:migrate`) adds a `modules` table for dynamic enabling/disabling, useful for feature flags or multi-tenant setups. Switch between them by publishing the config and running the migration.
How do I add a module-specific migration or config?
Use `php artisan module:make:migration` or `module:publish` to generate module-specific migrations/configs. Place them in `Modules/{Module}/Database/Migrations/` or `config/modules/{module}.php`. Publish them with `php artisan module:publish --module={Module}`. Migrations run alongside Laravel’s default migrations.
Are there alternatives to `nwidart/laravel-modules` for Laravel modularity?
Yes, but this package is the most mature and Laravel-idiomatic. Alternatives include **spatie/laravel-modules** (simpler but less feature-rich) or **orchid/platform** (full admin panel with modules). For microservices, consider **Laravel Horizon** + **Lumen** or **Spatie’s API resources**. This package stands out for its Artisan tooling, Vite support, and Laravel 11 compatibility.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport