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

Module Manager Laravel Package

nasirkhan/module-manager

Laravel module management for Laravel Starter: track module versions, handle migrations and updates, resolve dependencies, publish/enable/disable modules, scaffold/build modules, diff changes, and generate module tests via artisan commands.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Modular Monolith Alignment: The package excels in modular Laravel monoliths, where feature isolation, dependency management, and versioned modules are critical. It enforces a strict module structure (e.g., Modules/{Module}/) and namespace isolation, aligning with Laravel’s service provider and autoloading conventions.
  • Laravel Starter Dependency: Built for Laravel Starter, which may introduce hidden assumptions (e.g., laravel-jodit integration). If the base project diverges from Laravel Starter, customization overhead may arise.
  • Priority-Based Loading: The priority field in module.json enables load-order control, useful for core dependencies (e.g., Auth before Post). However, this requires discipline in configuration to avoid runtime conflicts.
  • Migration Tracking: The migration state tracking (module:track-migrations) mitigates "migration drift" risks but adds complexity to CI/CD pipelines (e.g., requiring track-migrations in deployment scripts).

Integration Feasibility

  • Laravel 12/13 Support: Requires PHP 8.3+, which may necessitate upgrades for legacy projects. Compatibility with Laravel 11 is untested.
  • Vendor vs. Published Modules:
    • Vendor Modules: Live in vendor/nasirkhan/module-manager/src/Modules/.
    • Published Modules: Copied to Modules/ via module:publish.
    • Risk: Namespace collisions if custom modules use the same names as vendor modules (e.g., Post). The package automatically rewrites namespaces during publishing, but this is a runtime behavior, not a compile-time check.
  • Dependency Resolution:
    • Circular Dependencies: The package does not enforce acyclic dependency graphs (e.g., A → B → A). This could lead to runtime errors if not manually validated.
    • Version Pinning: Relies on Composer version constraints for dependencies. If a module’s requires field is outdated, dependency satisfaction checks (module:dependencies) may fail silently.

Technical Risk

Risk Area Mitigation Strategy
Namespace Collisions Enforce unique module aliases in module.json and validate during module:build.
Migration Drift Automate module:track-migrations in pre-deployment hooks (e.g., GitHub Actions).
Performance Overhead Profile module:status and module:dependencies commands for large module counts.
Laravel Starter Lock-in Abstract Starter-specific logic (e.g., laravel-jodit) behind adapters if migrating away.
State Management Backup Modules/ and database/migrations before major updates to vendor modules.

Key Questions

  1. Module Isolation Needs:
    • Does the team require stronger isolation (e.g., microservices) or is a modular monolith sufficient?
    • If microservices are needed, this package adds complexity without solving distribution.
  2. Dependency Management:
    • How will module version upgrades be handled? (e.g., Post v1.0 → v2.0 with breaking changes.)
    • Is there a rollback strategy for failed module updates?
  3. CI/CD Impact:
    • Will module:track-migrations be automated in CI or require manual intervention?
    • How will test coverage be maintained for published modules?
  4. Customization Workflow:
    • Will the team publish all modules (module:publish --all) or selectively customize?
    • How will vendor updates (e.g., composer update) be tested against published modules?
  5. Performance:
    • What is the expected number of modules? (e.g., 10 vs. 100+ modules may impact module:status performance.)
    • Are there alternatives (e.g., Laravel Packages) for simpler use cases?

Integration Approach

Stack Fit

  • Best For:
    • Laravel 12/13 projects with modular architecture (e.g., SaaS platforms, CMS backends).
    • Teams using Laravel Starter or needing module scaffolding (e.g., module:build).
    • Projects requiring fine-grained feature toggling (enable/disable modules at runtime).
  • Poor Fit:
    • Microservices or decoupled architectures (this package enforces monolithic module structure).
    • Projects with legacy PHP < 8.3 or Laravel < 12.
    • Teams preferring package-based isolation (e.g., standalone Composer packages).

Migration Path

  1. Assessment Phase:
    • Audit existing routes, migrations, and service providers to identify collisions with the package’s structure.
    • Decide on module strategy: Will existing features be refactored into modules or coexist?
  2. Initial Setup:
    composer require nasirkhan/module-manager
    php artisan module:build {ModuleName}  # For new modules
    php artisan vendor:publish --tag=module-manager-config  # Publish config
    
  3. Incremental Adoption:
    • Phase 1: Migrate non-critical modules (e.g., Tag, Category) to test workflows.
    • Phase 2: Integrate core modules (e.g., Auth, Post) with dependency validation.
    • Phase 3: Automate migration tracking and dependency checks in CI.
  4. Legacy Integration:
    • For non-module code, use service providers to conditionally load based on module status:
      if (app(ModuleVersion::class)->isEnabled('Post')) {
          require base_path('Modules/Post/routes/web.php');
      }
      

Compatibility

Component Compatibility Notes
Laravel Packages May conflict if they register routes/migrations without module awareness.
Custom Service Providers Must defer to module managers or risk load-order issues.
Database Migrations Existing migrations not tracked by default; require module:track-migrations.
Livewire/Blade Works seamlessly if modules follow the Modules/{Module}/Resources/views/ structure.
API Routes Requires module-aware route registration (e.g., Route::module('post', ...)).

Sequencing

  1. Prerequisites:
    • Upgrade to PHP 8.3+ and Laravel 12/13.
    • Ensure Composer autoload is optimized (composer dump-autoload --optimize).
  2. Core Integration:
    • Publish the package config and migration tracker:
      php artisan vendor:publish --tag=module-manager-config
      php artisan vendor:publish --tag=module-manager-migrations
      
  3. Module Lifecycle:
    • BuildPublishEnableTestDeploy.
    • Example workflow:
      php artisan module:build UserProfile
      php artisan module:publish UserProfile
      php artisan module:enable UserProfile
      php artisan module:track-migrations UserProfile
      php artisan migrate
      
  4. Post-Deployment:
    • Automate dependency checks in CI:
      # .github/workflows/ci.yml
      - name: Check Module Dependencies
        run: php artisan module:dependencies --fail-on-error
      
    • Schedule regular migration tracking (e.g., weekly):
      php artisan module:detect-updates --all
      

Operational Impact

Maintenance

  • Pros:
    • Centralized Module Management: All modules are versioned and trackable via module.json.
    • Automated Scaffolding: Reduces boilerplate for new modules (module:build).
    • Dependency Visualization: module:dependencies helps debug runtime errors early.
  • Cons:
    • Additional Artisan Commands: Team must learn 15+ new commands (e.g., module:diff, module:remove).
    • Configuration Overhead: Each module requires module.json maintenance.
    • Vendor Lock-in: Customizations to Laravel Starter may not port to other bases.

Support

  • Debugging Workflow:
    1. Check Status: php artisan module:status --all
    2. Validate Dependencies: php artisan module:dependencies {module}
    3. Compare Versions: php artisan module:diff {module} --detailed
    4. Clear Caches: `php
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.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
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