- How do I create a new module with internachi/modular?
- Use the extended Artisan commands with the `--module` flag, like `php artisan make:model User --module=users`. This generates the model inside `app-modules/users/` with proper namespacing. The package leverages Laravel’s package discovery, so no extra bootstrapping is needed after creation.
- Does internachi/modular work with Laravel 11+ only?
- Yes, this package explicitly targets Laravel 11+ to align with modern features like Eloquent model factories and Blade components. Older versions (pre-9.x) are unsupported, as the package relies on Laravel’s updated package discovery system.
- Can I share modules as standalone Composer packages?
- No, modules are tied to your project via Composer path repositories, which are project-specific. To share a module, you’d need to refactor it into a standalone package and manually manage dependencies. The package prioritizes simplicity over portability.
- How does dependency management work across modules?
- Modules declare dependencies in their own `composer.json`, but shared dependencies (like `laravel/framework`) must be managed at the root level to avoid conflicts. Peer dependencies (e.g., `spatie/laravel-permission`) can be specified per module, but conflicts must be resolved manually.
- Will this slow down `composer install` in large projects?
- Yes, scanning `app-modules/*` for auto-discovery can add overhead, especially with many modules. For CI/CD pipelines, consider caching Composer dependencies or running `composer install --no-scripts` to mitigate this.
- How do I namespace Blade components for modules?
- Use the namespaced syntax `<x-module::component>` in Blade templates. The package auto-discovers components under `resources/views/module/` with proper namespacing, so no extra configuration is required beyond following the `app-modules/` structure.
- Can I use module-specific database migrations?
- Yes, run `php artisan db:seed --module=users` to execute module-scoped migrations or seeders. Migrations are stored in `database/migrations/module/` and follow Laravel’s standard migration conventions.
- What IDE support is available for modules?
- PhpStorm syncs automatically with the `app-modules/` structure, but other IDEs (like VSCode) may require manual configuration. The package provides no built-in tooling for dynamic IDE integration, so custom setups or source maps may be needed.
- How do I test modules without cluttering the root phpunit.xml?
- Use the `modules:sync` command to integrate module-specific tests into the root test suite. However, this can clutter the configuration. For better isolation, consider splitting tests into separate suites or using module-specific `TestCase` base classes.
- What’s the difference between this and nwidart/laravel-modules?
- This package is lighter, using Laravel’s native package discovery and Composer path repos instead of introducing new abstractions. It lacks dynamic module loading/unloading (e.g., plugins) but avoids vendor lock-in. `nwidart/laravel-modules` offers more features but with heavier tooling.