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

Modularity Laravel Package

wandypurnomo/modularity

Laravel package for building modular applications with a clean module structure. Organize features into self-contained modules, manage module discovery and loading, and keep codebases scalable and maintainable.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Modular Design Alignment: The package promotes a modular Laravel architecture, which aligns well with Domain-Driven Design (DDD), Microservices-inspired monoliths, or feature-based decomposition. This is particularly valuable for:
    • Large-scale applications with distinct business domains (e.g., e-commerce, SaaS platforms).
    • Teams requiring logical separation of concerns (e.g., frontend, backend, third-party integrations).
    • Projects where independent deployment of modules (e.g., via Laravel Forge/Envoyer) is a future goal.
  • Laravel Ecosystem Synergy: Leverages Laravel’s service providers, facades, and autoloading natively, reducing friction with existing codebases.
  • Potential Overhead: May introduce indirection (e.g., module bootstrapping, namespace resolution) if the project is small or already modular. Risk of over-engineering for greenfield projects.

Integration Feasibility

  • Core Laravel Compatibility: Works with Laravel 8+ (likely due to dependency on illuminate/support). Assumes PSR-4 autoloading and Composer for module discovery.
  • Existing Module Systems: Could replace or coexist with custom modular patterns (e.g., app/Modules/, lumens/ignition-style modules). May conflict with:
    • Laravel Nova/Panel integrations (if modules are tightly coupled to admin panels).
    • Package-based modularity (e.g., spatie/laravel-package-tools).
  • Database/Schema Management: No explicit ORM (Eloquent) or migration support mentioned. Assumes manual schema handling per module or integration with tools like:
    • laravel-migrations-generator
    • spatie/laravel-model-states

Technical Risk

Risk Area Mitigation Strategy
Namespace Collisions Enforce strict module prefixes (e.g., App\Modules\Auth\...) in composer.json.
Performance Overhead Benchmark module bootstrapping vs. monolithic approach. Use lazy-loading for non-critical modules.
Dependency Isolation Test module autoloading in isolation (e.g., composer dump-autoload --optimize).
Legacy Code Impact Gradual migration: Start with non-critical modules (e.g., reporting, analytics).
Documentation Gaps Contribute to or create internal runbooks for module lifecycle (install, update, debug).

Key Questions

  1. Why Modularity Now?
    • Is this for scalability, team isolation, or tech debt reduction? Prioritize accordingly.
  2. Module Granularity
    • Should modules align with business domains (e.g., Billing, Inventory) or technical layers (e.g., Auth, Payments)?
  3. Deployment Strategy
    • Will modules be monorepo (single Laravel install) or multi-repo (separate Git repos)?
  4. Shared Dependencies
    • How will cross-module services (e.g., caching, queues) be managed? Avoid circular dependencies.
  5. Testing Scope
    • Will modules require isolated test environments? Consider tools like orchestra/testbench for module-specific tests.
  6. CI/CD Pipeline
    • How will module versioning and deployment be handled? (e.g., Git tags, Composer packages).

Integration Approach

Stack Fit

Laravel Component Integration Strategy
Service Providers Convert existing providers to module-aware (e.g., App\Modules\Auth\AuthServiceProvider).
Routes Use Module::routes() or Module::web()/Module::api() for module-specific routes.
Middleware Register middleware per module (e.g., Auth::middleware('auth')->module('auth')).
Views Leverage Module::view() or namespace views (e.g., resources/modules/auth/views).
Migrations Prefix migrations with module name (e.g., 2023_01_01_000000_create_auth_users_table.php in database/migrations/modules/auth/).
Commands/Jobs Group Artisan commands and queue jobs under module namespaces (e.g., App\Modules\Auth\Console\...).
Events/Listeners Use module-specific event namespaces (e.g., Auth\UserRegistered).

Migration Path

  1. Assessment Phase
    • Audit current codebase for tight couplings (e.g., global service containers, shared config).
    • Identify candidate modules (start with 2–3 low-risk domains).
  2. Pilot Module
    • Refactor a non-critical feature (e.g., blog, support ticketing) into a module.
    • Test autoloading, routing, and dependency injection.
  3. Incremental Rollout
    • Phase 1: Move configurable components (e.g., settings, plugins).
    • Phase 2: Isolate domain-specific logic (e.g., Order, User).
    • Phase 3: Migrate shared services (e.g., logging, caching) to module-agnostic layers.
  4. Tooling Setup
    • Configure Composer scripts for module generation:
      "scripts": {
        "module:create": "php artisan module:make {name} --namespace=App\\Modules"
      }
      
    • Set up module-specific testing (e.g., phpunit.xml per module).

Compatibility

  • Laravel Packages: May require adaptation if packages assume global service binding (e.g., spatie/laravel-permission). Solutions:
    • Use module-specific package configurations.
    • Abstract package services into module-aware facades.
  • Third-Party APIs: Ensure API clients are instantiated per module to avoid shared state issues.
  • Legacy Code: Use adapters to bridge monolithic services into modular calls (e.g., Auth::module('legacy')->attempt()).

Sequencing

  1. Foundational Modules
    • Start with core domains (e.g., Auth, User, Payment) to establish patterns.
  2. Infrastructure Modules
    • Add cross-cutting concerns (e.g., Logging, Notifications) last to avoid early abstraction.
  3. UI Integration
    • For Blade/Inertia/Vue, use module-specific view paths and dynamic imports (e.g., import('@modules/auth/components/Login')).
  4. API Layer
    • Expose module routes via API gateways (e.g., Laravel’s Route::prefix('api/v1')) or GraphQL modules (e.g., rebing/graphql-laravel).

Operational Impact

Maintenance

  • Pros:
    • Isolated updates: Modules can be updated independently (e.g., composer require vendor/module:2.0.0).
    • Ownership clarity: Teams can own entire modules (e.g., frontend team for Auth, backend for Payments).
  • Cons:
    • Module sprawl: Too many small modules increase context-switching and build complexity.
    • Debugging overhead: Stack traces may require module-aware IDE plugins (e.g., PHPStorm’s "Go to Module").
  • Mitigations:
    • Enforce module size limits (e.g., <500 LOC).
    • Use module health checks (e.g., php artisan module:status).

Support

  • Troubleshooting:
    • Module isolation: Failures in one module should not crash others (test with php artisan module:disable).
    • Logging: Implement module-scoped log channels (e.g., monolog with module prefixes).
  • User Impact:
    • Downtime: Plan for module-by-module deployments (use Laravel’s queue workers for async tasks).
    • Rollbacks: Support module versioning (e.g., composer require vendor/module:1.2.0).
  • Documentation:
    • Maintain a module dependency graph (tools: php-dependency-graph, custom scripts).
    • Create runbooks for common module operations (e.g., "How to update the Auth module").

Scaling

  • Horizontal Scaling:
    • Modules can be deployed independently (e.g., Auth module on a separate Forge server).
    • Use Laravel Horizon for module-specific queue workers.
  • Performance:
    • Lazy-load non-critical modules (e.g., `
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.
aimeos/prisma
besmartand-pro/php-quality-config
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views