internachi/modularize
Adds InterNACHI Modular support to Laravel Artisan commands. Use the Modularize traits to add a --module option so commands and generator commands can target a specific module, placing generated files in the module directory with correct namespaces.
spatie/laravel-package-tools). This approach minimizes code duplication and adheres to Laravel’s dependency injection and service container principles. The declarative trait usage (use Modularize) ensures low cognitive load for package authors while maintaining extensibility via method overrides (e.g., getDefaultNamespace()).ModuleConfig. This introduces moderate technical risk (~30%), as edge cases (e.g., dynamic module discovery) are not natively supported. The package’s hook-based design mitigates this by allowing granular control, but testing with complex module hierarchies is critical.ModularizeGeneratorCommand trait is highly targeted for file generators (e.g., make:controller), automating module-aware path/namespace logic. This reduces boilerplate by ~90% but excludes non-generator commands, which must use the lighter Modularize trait. This deliberate tradeoff ensures simplicity but may require custom logic for commands with unique file-generation needs.internachi/modular Dependency: The package’s reliance on internachi/modular introduces vendor lock-in risk, as changes to ModuleConfig or module resolution logic could break compatibility. However, the MIT license and open-source nature of internachi/modular reduce this risk. Mitigation: Conduct a compatibility audit of internachi/modular’s API stability and consider abstraction layers (e.g., interfaces) if long-term flexibility is required.internachi/modularize).use Modularize or use ModularizeGeneratorCommand).--module flag required).Command, GeneratorCommand).--module flag integrates with internachi/modular’s module resolution system, but custom module discovery logic (e.g., runtime tenant-based modules) may require additional configuration. Test with multi-tenant SaaS use cases to validate edge cases.modules/{tenant}/{module}) may need manual overrides in getDefaultNamespace(). Document these edge cases for package authors.internachi/modular Stability: Breaking changes in ModuleConfig or module resolution could necessitate package updates.internachi/modular behind an interface to isolate dependencies.internachi/modular and Laravel’s console component updates for breaking changes.--module flag.internachi/modular?
internachi/modular as a dependency).queue:work), the package provides limited value (only basic module access).spatie/laravel-modules), evaluate lock-in risk and migration effort.internachi/modular updates?
internachi/modular, but not exclusive—could be adapted for other modular systems (e.g., spatie/laravel-modules) with minimal refactoring. However, this introduces maintenance overhead.make:controller, make:migration). End-user applications should not depend directly on this package (it’s a package author tool).internachi/modular is installed and configured.composer require internachi/modularize
use InterNACHI\Modularize\Support\Modularize;
class MyCommand extends Command { use Modularize; }
use InterNACHI\Modularize\Support\ModularizeGeneratorCommand;
class MakeWidget extends GeneratorCommand { use ModularizeGeneratorCommand; }
--module flag works with existing modules.modules/{module}/Http/Controllers/).Modules\Blog\Http\Controllers\WidgetController).getDefaultNamespace() for custom paths.internachi/modular: Required dependency (no alternatives provided).Modularize trait).How can I help you explore Laravel packages today?