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

Product Decisions This Supports

  • Modular Monolith Architecture: Enables teams to decompose large Laravel applications into self-contained modules (e.g., Auth, Payments, Inventory), improving maintainability and scalability. Aligns with the "microservices-lite" pattern for monolithic apps.
  • Feature-Flagged Development: Supports gated feature rollouts by enabling/disabling modules via module:enable/disable commands or database-backed activators (v6+). Critical for canary releases or A/B testing.
  • Team Autonomy: Isolates codebases for cross-functional teams (e.g., frontend, backend, analytics) by assigning modules to owners. Reduces merge conflicts and promotes feature ownership.
  • Legacy System Integration: Facilitates gradual migration of monolithic apps by encapsulating legacy components as modules. Example: Wrap an old CRM module alongside new Ecommerce features.
  • Build vs. Buy: Avoids reinventing module systems (e.g., custom Composer autoloading, route isolation, or service provider logic). Saves 3–6 months of dev time vs. a bespoke solution.
  • Tech Debt Reduction: Standardizes module scaffolding (e.g., module:make:controller, module:make:model) with consistent stubs and type hints, reducing boilerplate.
  • Multi-Tenancy: Enables tenant-specific modules (e.g., Saas/Tenant1/Features) by combining with packages like stancl/tenancy.

When to Consider This Package

Adopt if:

  • Your Laravel app exceeds 50K+ LoC or has >3 teams contributing to the codebase.
  • You need dynamic feature toggling (e.g., disable Marketing module during holidays).
  • Your team uses Composer and Laravel’s ecosystem (avoids framework lock-in).
  • You require asset compilation isolation (Vite/Laravel Mix per-module support).
  • You’re migrating from a monolith to microservices and want a phased approach.

Look elsewhere if:

  • Your app is <10K LoC or has <2 teams (overhead isn’t justified).
  • You need true microservices (use Lumen or Sail instead).
  • Your stack is non-PHP (e.g., Node.js, Python).
  • You require real-time module hot-reloading (consider Livewire or Inertia.js for SPAs).
  • Your team lacks Composer/Laravel familiarity (steep learning curve for module conventions).

How to Pitch It (Stakeholders)

For Executives (1 Slide)

Problem: "Our Laravel monolith is a ‘big ball of mud’—slow releases, high merge conflicts, and teams stepping on each other’s code. Tech debt is growing, and new features take 3x longer to ship."

Solution: "Laravel Modules lets us decompose the app into self-contained features (e.g., Auth, Payments) that teams can own, test, and deploy independently. Think ‘microservices for monoliths’—with 30% faster releases and 50% less merge hell."

ROI:

  • Dev Velocity: Teams work in parallel without blocking each other.
  • Cost Savings: Avoids custom module systems (estimated $150K+ in dev time).
  • Scalability: Supports 10x growth without architectural overhauls.
  • Risk Mitigation: Disable broken modules instantly (e.g., module:disable Payments).

Ask: "Approve a 2-week spike to prototype modules for our top 3 features (Auth, Billing, Analytics). If successful, we’ll roll it out to the full team."


For Engineering (Deep Dive)

Why This Package?

  1. Standardized Module Structure:

    • Auto-generates ModuleServiceProvider, routes/web.php, migrations, and stubs via module:make.
    • Example:
      php artisan module:make Auth --controller --migration --resource
      
    • Outputs a self-contained Modules/Auth/ with:
      • Http/Controllers/AuthController.php
      • Database/Migrations/...
      • Resources/views/auth/...
      • Routes/web.php (isolated routes).
  2. Dynamic Enablement:

    • Toggle modules without code changes:
      php artisan module:disable Marketing  # Turn off during Q4
      php artisan module:enable Analytics   # A/B test new features
      
    • Database-backed activation (v6+) for audit trails:
      // config/modules.php
      'activator' => \Nwidart\Modules\DatabaseActivator::class,
      
  3. Asset Isolation:

    • Vite/Laravel Mix per-module:
      // Modules/Auth/resources/js/auth.js
      import './auth.js'; // Compiled separately
      
    • Avoids global CSS/JS conflicts.
  4. Tooling for Scale:

    • Artisan Commands:
      Command Use Case
      module:make:controller Generate controllers with --api/ --web flags.
      module:make:model Includes --factory/ --migration.
      module:seed Seed data per-module.
      module:update Sync all modules to latest stubs.
    • Testing: Built-in PHPUnit support for module isolation.
  5. Migration Path:

    • Phase 1: Wrap 3 critical features (e.g., Auth, Payments) as modules.
    • Phase 2: Gradually move remaining logic into modules.
    • Phase 3: Use database activators for feature flags.

Risks & Mitigations:

Risk Mitigation
Learning curve for modules. 1-day workshop + cheat sheet.
Route conflicts. Module-specific RouteServiceProvider.
Asset compilation slowdown. Parallelize Vite builds per-module.

Next Steps:

  1. Spike: Convert Auth module in 2 days (proof of concept).
  2. Document: Create a module style guide for the team.
  3. Onboard: Train devs on module:make commands and activation workflows.

Alternatives Considered:

  • Custom solution: Would take 3 months and lack community support.
  • Lumen microservices: Overkill for monolith decomposition.
  • No change: Risks technical debt explosion as the codebase grows.
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