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

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.

View on GitHub
Deep Wiki
Context7

Add support for internachi/modular to existing packages

Frequently asked questions about Modularize
How do I add modular support to an existing Laravel Artisan command?
Use the `Modularize` trait in your command class. This adds a `--module` option and provides a `module()` method to access the module configuration. No other changes are needed for basic modular access.
Does this work with Laravel 12 or older versions?
No, this package explicitly supports Laravel 13+ due to its dependency on Symfony 7.x. If you’re on Laravel 12 or earlier, you’ll need an alternative solution or to upgrade.
Can I use this with spatie/laravel-package-tools for modular packages?
Yes, this package is designed to integrate seamlessly with modular package architectures like spatie/laravel-package-tools. The traits work alongside package tools to ensure generated files respect module-specific paths and namespaces.
What happens if I don’t specify the --module flag?
Commands remain fully functional without the `--module` flag. The package ensures backward compatibility, so existing workflows aren’t disrupted during adoption.
How does the ModularizeGeneratorCommand trait handle file generation?
The `ModularizeGeneratorCommand` trait automatically places generated files in the correct module directory and updates namespaces dynamically. It’s optimized for Laravel’s built-in generators like `make:controller` or `make:migration`.
What if my module structure doesn’t follow PSR-4 conventions?
You can override the default behavior by extending the traits or customizing the `ModuleConfig` methods. The package provides hooks like `getDefaultNamespace()` to handle non-standard paths or nested modules.
Is there a risk of vendor lock-in with internachi/modular?
Yes, since this package depends on `internachi/modular`, changes to its API or configuration could require updates. However, the MIT license and open-source nature allow collaborative fixes, reducing long-term risks.
Can I use this for custom file generators beyond Laravel’s defaults?
The `ModularizeGeneratorCommand` trait is designed for Laravel’s built-in generators. For custom generators, you may need to extend the trait or manually handle module-aware paths and namespaces.
How do I test modular commands in CI or locally?
Mock the `ModuleConfig` instance in your tests to simulate module-specific behavior. Ensure your CI validates namespace consistency and file paths for generated artifacts across modules.
Are there alternatives to internachi/modularize for modular Laravel packages?
For Laravel 10/11, consider `spatie/laravel-package-tools` with custom logic or `nWidart/laravel-modules`. For Laravel 13+, this package is one of the few optimized for modular command support with minimal boilerplate.
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai