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

Laravel Modules Laravel Package

nwidart/laravel-modules

Modularize large Laravel apps with nwidart/laravel-modules. Create self-contained modules (controllers, models, views, routes, config) with Artisan generators, module discovery, enabling/disabling, and per-module resources—tested and maintained across modern Laravel versions.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Modular Monolith Advantage: The package excels in Laravel-based modular monoliths, enabling feature isolation, independent deployment, and team autonomy without full microservices overhead. Ideal for:
    • Large-scale applications (e.g., SaaS platforms, enterprise systems).
    • Teams requiring domain-driven separation (e.g., AuthModule, BillingModule).
    • Projects with gradual migration needs (e.g., splitting legacy monoliths).
  • Alignment with Laravel Ecosystem:
    • Seamless integration with Laravel’s service providers, routes, migrations, and artisan commands.
    • Supports Vite/Laravel Mix for asset compilation per module.
    • Compatible with Laravel’s dependency injection and facades.
  • Trade-offs:
    • Not a microservice solution: Modules share the same database, session, and process (no true isolation).
    • Performance overhead: Module activation/deactivation introduces runtime checks (though mitigated by caching).

Integration Feasibility

  • Core Laravel Compatibility:
    • Works with Laravel 11–13 (PHP 8.1+). Backward compatibility exists for older versions but requires version-specific configs.
    • Supports Laravel’s first-party packages (e.g., Sanctum, Cashier) if modules are designed to include them.
  • Third-Party Package Risks:
    • Potential conflicts with packages that hook into Laravel’s bootstrapping (e.g., spatie/laravel-package-tools). Requires explicit module registration order.
    • Database migrations: Modules must handle shared vs. isolated schemas (e.g., module_name_* prefixes).
  • Tooling Integration:
    • Artisan commands: Extends Laravel’s CLI with module:make, module:publish, module:seed, etc.
    • IDE Support: Works with PHPStorm/Laravel IDE Helper for autocompletion (if merge-plugin is configured).
    • Testing: Supports Pest/PHPUnit via module-specific test suites.

Technical Risk

Risk Area Severity Mitigation
Module Isolation High Use database prefixes, separate service providers, and namespace guards.
Asset Compilation Medium Configure Vite/Laravel Mix per module to avoid global conflicts.
Dependency Management Medium Document module interdependencies (e.g., AuthModule required for BillingModule).
Performance Low Enable module caching (config['modules']['cache_enabled'] = true).
Upgrade Path Medium Test major version upgrades (e.g., v10→v11) in a staging environment.
Debugging Complexity High Implement module-specific logging (e.g., Module::getName() in logs).

Key Questions for TPM

  1. Architectural Goals:
    • Is the goal modularity for scalability (e.g., independent deployments) or code organization?
    • Will modules be deployed as a unit (e.g., via Docker) or individually?
  2. Database Strategy:
    • How will shared vs. isolated data be handled? (e.g., multi-tenancy, schema separation)
    • Are cross-module transactions required?
  3. Team Structure:
    • Will teams own entire modules or collaborate on shared modules?
    • How will module boundaries be enforced (e.g., via CI/CD pipelines)?
  4. Legacy Integration:
    • How will existing non-modular code be incrementally migrated?
    • Are there critical paths that cannot be modularized?
  5. Performance SLAs:
    • What is the acceptable overhead for module activation checks?
    • Will caching strategies (e.g., Redis) be used to mitigate runtime costs?
  6. Tooling & CI/CD:
    • How will module-specific testing/deployment be automated?
    • Will feature flags be used to toggle modules at runtime?

Integration Approach

Stack Fit

  • Laravel Versions: 11–13 (PHP 8.1+). Avoid mixing versions (e.g., Laravel 10 + v13 modules).
  • PHP Extensions: No additional extensions required beyond Laravel’s defaults.
  • Frontend: Vite/Laravel Mix support per module (requires vite.config.js per module).
  • Databases:
    • MySQL/PostgreSQL: Native support for migrations/seeds.
    • SQLite: Limited support (no multi-database transactions).
  • Caching: Redis/Memcached recommended for module activation caching.
  • Queue Systems: Database queues or Redis for module-specific jobs.

Migration Path

Phase Steps Tools/Commands
Evaluation Audit existing codebase for high-cohesion, low-coupling components. Manual review + php artisan module:discover
Scaffolding Set up module structure (modules/ directory, composer.json merge-plugin). composer require nwidart/laravel-modules
Incremental Migration Convert one feature/module at a time (e.g., Auth, Reports). php artisan module:make Auth
Dependency Mapping Document module dependencies (e.g., BillingAuth). Manual + module:list
Asset Isolation Configure Vite/Laravel Mix per module (e.g., resources/js/modules/Auth.js). vite.config.js per module
Database Schema Use module-specific migrations (e.g., module_name_users table). php artisan module:migrate Auth
Testing Write module-specific tests (Pest/PHPUnit) and integration tests for cross-module flows. php artisan module:test Auth
Deployment Deploy modules independently (e.g., via Docker, zero-downtime updates). CI/CD pipelines
Monitoring Add module-specific logging (e.g., Module::getName() in logs). Laravel Log + ELK/Stackdriver

Compatibility

  • Laravel Packages:
    • Compatible: Most first-party packages (e.g., laravel/breeze, spatie/laravel-permission) if modules include them.
    • Risky: Packages that hook into boot() or service providers (e.g., spatie/laravel-package-tools). Solution: Explicitly register in module’s ModuleServiceProvider.
  • Custom Code:
    • Facades: Replace with explicit bindings (e.g., Auth::user()app(AuthManager::class)->user()) if modules are isolated.
    • Global Helpers: Move to module-specific helpers (e.g., AuthHelper in AuthModule).
  • Legacy Systems:
    • Monolithic Controllers: Refactor into module-specific controllers (e.g., AuthModule/Http/Controllers/AuthController).
    • Shared Services: Use Laravel’s container to bind interfaces (e.g., AuthServiceInterface).

Sequencing

  1. Pre-Integration:
    • Define module boundaries (e.g., via event storming).
    • Set up base module structure (modules/ dir, composer.json merge-plugin).
    • Configure database prefixes or multi-tenancy strategy.
  2. Core Integration:
    • Install package: composer require nwidart/laravel-modules.
    • Publish config: php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider".
    • Enable merge-plugin for autoloading.
  3. Module Creation:
    • Generate first module: php artisan module:make Auth --controller --migration.
    • Test module isolation: php artisan module:disable Auth (verify no Auth routes/helpers work).
  4. Asset Pipeline:
    • Configure Vite/Laravel Mix per module (e.g., vite.config.js in AuthModule).
    • Test asset compilation: npm run dev --filter=AuthModule.
  5. Database:
    • Run migrations: php artisan module:migrate Auth.
    • Seed data: php artisan module:seed Auth.
  6. Testing:
    • Write module-specific tests (e.g., tests/Module/AuthModuleTest).
    • Test **cross-module interactions
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.
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
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata