- What is laravel-modules and when should I use it in a Laravel app?
- laravel-modules is a modular-monolith package for Laravel that lets you split an application into self-contained modules, each with its own controllers, models, views, routes, migrations, translations, and service providers. Use it when you need bounded contexts and clear team ownership inside a single deployable application, not when you want independent services or runtime plugin isolation. It is a good fit for growing Laravel codebases where domains like billing, catalog, or support need their own folders and conventions.
- How do I install and register laravel-modules in a Laravel project?
- Installation is Composer-based: run composer require for the package, then register its service provider following the package documentation. After that, Artisan commands such as module:make, module:enable, and module:disable become available for scaffolding and managing modules. Adoption is incremental, so you can create one module and leave the rest of the application untouched while you validate the conventions.
- Is aiwozhe/laravel-modules the same package as nwidart/laravel-modules?
- The Composer identifier aiwozhe/laravel-modules does not match the repository nWidart/laravel-modules, so this is most likely a fork or a typosquat rather than the canonical package. Verify provenance before installing by checking the package author, the repository URL in composer.json, and the release history, and never install both this package and the upstream nwidart/laravel-modules in the same application. If you cannot confirm it is an authorized fork with release parity, prefer the canonical package.
- Which Laravel and PHP versions does laravel-modules support?
- Version support depends entirely on the specific release you install, so check the require constraints in the package composer.json and the tag you are pinning. Laravel-modules generally tracks recent Laravel majors, but a fork may lag upstream patches and drop or miss newer Laravel and PHP versions. Confirm compatibility with your exact Laravel and PHP versions in a CI job before adopting it in production.
- How do I create, enable, and disable a module with Artisan commands?
- The module:make command scaffolds a new module directory with the standard structure, including a service provider, routes, and optional stubs for controllers, models, and migrations. Module status is tracked in a modules configuration file, so module:enable and module:disable toggle whether a module's providers and routes are loaded without deleting code. This makes it practical to ship a module dark, test it in staging, and enable it later.
- Do laravel-modules modules have their own migrations, routes, views, and translations?
- Yes. Each module is a self-contained directory with its own service providers, and it can register routes, load views, load translations, and publish or run migrations from its own paths. The package handles discovery so Laravel loads these resources without extra wiring in the main application. The tradeoff is convention: namespaces, PSR-4 autoloading, and migration ordering must be standardized across modules to avoid collisions.
- Does laravel-modules work with route caching and config caching in production?
- Modules register routes and configuration through service providers, so cached routes and cached config still work as long as discovery runs at build time in the same way it does locally. Common production issues come from environment-specific paths, stale caches after enabling or disabling a module, or modules that register routes conditionally. Run php artisan route:cache and config:cache in staging after any module change to confirm behavior.
- Can laravel-modules give me independently deployable services or microservices?
- No. laravel-modules provides organizational separation inside one Laravel application deployment; it does not offer runtime isolation, independent deployment pipelines, or cross-language boundaries. The architectural benefit is team ownership and cleaner domain boundaries, not infrastructure separation. If you genuinely need independent services, modular monolith tooling will not get you there and you should plan a service extraction instead.
- How should I test a module and integrate it with my existing test suite?
- Because a module is a normal Laravel package structure registered via a service provider, its tests can run through your existing PHPUnit or Pest setup with the appropriate namespace mapping. Write feature tests that hit module routes through the application kernel, and unit tests for module services and repositories. Keep a CI job that runs the full suite with modules enabled so cross-module regressions surface early.
- What are the alternatives to laravel-modules and how does it compare?
- The canonical alternative is upstream nwidart/laravel-modules, which this identifier appears to fork; you should compare them directly before choosing. Other approaches include plain domain-oriented folders within a single app namespace, or Composer path repositories for locally developed packages. laravel-modules stands out for its Artisan scaffolding, module lifecycle commands, and bundled support for routes, views, migrations, and translations, which is more turnkey than hand-rolled domain folders.