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

Modularize Laravel Package

internachi/modularize

Add InterNACHI Modular support to your Laravel package commands with simple traits. Provides a --module option and helpers to resolve module config. Includes a GeneratorCommand trait so generated files land in the module directory with correct namespaces.

View on GitHub
Deep Wiki
Context7

Add support for internachi/modular to existing packages

Frequently asked questions about Modularize
How do I add a --module option to my custom Laravel Artisan command?
Use the `Modularize` trait in your command class. This automatically injects the `--module` flag and provides a `module()` method to access module configuration (name, path, namespace) when the flag is used. No additional setup is required beyond adding the trait.
Will this work with Laravel 12 or older versions?
No, internachi/modularize is explicitly designed for Laravel 13+ due to its reliance on Symfony 7.x console components. If you're on Laravel 12 or earlier, you’ll need to upgrade or explore alternative modular solutions like spatie/laravel-package-tools.
Can I use this for non-generator commands like `php artisan queue:work`?
The `Modularize` trait supports non-generator commands by adding the `--module` flag, but it doesn’t handle file system operations. For commands requiring module-aware file placement (e.g., migrations, controllers), use `ModularizeGeneratorCommand` instead, which automates directory and namespace logic.
How does the package handle custom module paths or non-PSR-4 namespaces?
By default, the package assumes PSR-4 module structures. For custom paths or namespaces, override the `getDefaultNamespace()` or `getModulePath()` methods in your `ModuleConfig`. This requires manual configuration but maintains flexibility for non-standard setups.
Does this package work with spatie/laravel-package-tools?
Yes, internachi/modularize is designed to integrate seamlessly with spatie/laravel-package-tools. It extends package commands with modular support while preserving existing functionality, making it ideal for modular monoliths or package-based architectures.
What if my module uses a deeply nested directory structure?
The package supports nested modules out of the box, but you may need to customize the `ModuleConfig` to reflect your exact path structure. Test thoroughly with your module hierarchy to ensure generated files land in the correct locations.
Is there runtime overhead when using this package?
No, internachi/modularize introduces zero runtime overhead. The traits only activate when the `--module` flag is used, and all logic is resolved during command execution without impacting performance in non-modular workflows.
How do I test commands that use the --module flag?
Use Laravel’s `artisan` helper in tests to simulate the `--module` flag, e.g., `artisan('your:command', ['--module' => 'module-name'])`. Mock the `ModuleConfig` if needed to isolate module-specific behavior during unit testing.
What happens if internachi/modular gets a breaking change?
Since internachi/modularize is tightly coupled to internachi/modular, breaking changes in the parent package may require updates. Monitor the internachi/modular changelog and test thoroughly after updates to ensure compatibility with your commands.
Are there alternatives to this package for Laravel modular commands?
For Laravel 12 or older, consider spatie/laravel-package-tools or custom solutions using Laravel’s service providers. For Laravel 13+, alternatives like laravel-modules or bespoke trait-based implementations exist, but internachi/modularize offers the most streamlined integration with internachi/modular’s ecosystem.
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.
codraw/entity-migrator
codraw/doctrine-extra
codraw/aws-tool-kit
codraw/validator
codraw/workflow
codraw/open-api
codraw/cron-job
codraw/process
codraw/log
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony