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

Monorepo Builder Laravel Package

symplify/monorepo-builder

Tools for PHP monorepos: scaffold a repo, merge package composer.json files into the root, validate shared dependency versions, bump inter-package constraints, propagate versions back to packages, and automate releases via a single monorepo-builder.php config.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Monolithic-to-Monorepo Transition: Ideal for PHP projects evolving from a monolithic architecture to a monorepo structure, particularly those using Composer. Aligns with modern PHP ecosystems (e.g., Symfony, Laravel) where modularity and shared dependencies are critical.
  • Laravel-Specific Fit: While not Laravel-native, it integrates seamlessly with Laravel’s Composer-based dependency management. Laravel’s modular plugins (e.g., packages in packages/) or multi-tenant SaaS architectures would benefit from this tool’s version alignment and dependency management.
  • Toolchain Synergy: Complements existing Laravel tools like Laravel Mix, Vite, or Pest (if used in a monorepo) by centralizing dependency management at the root level.

Integration Feasibility

  • Low Friction: Leverages Composer, a core Laravel dependency, reducing integration overhead. No PHP framework-specific modifications required.
  • Configuration-Driven: Centralized monorepo-builder.php allows fine-grained control over merge strategies (e.g., excluding dev dependencies, custom paths).
  • CI/CD Friendly: Commands (merge, release) are scriptable and can be embedded in Laravel’s CI pipelines (GitHub Actions, GitLab CI) for automated dependency sync.

Technical Risk

  • Version Skew Risks: Merging composer.json files may introduce conflicts if packages have divergent version constraints (e.g., ^5.0 vs. ~6.0). Mitigation: Use monorepo-builder's validation rules or pre-merge checks.
  • Caching Complexity: Laravel’s autoloader (PSR-4) may need adjustments if packages share namespaces. Risk: Low if namespaces are scoped (e.g., Vendor\Package\*).
  • Tooling Ecosystem: Limited Laravel-specific documentation (e.g., handling vendor/ symlinks, Laravel-specific composer.json keys like extra.laravel). Requires manual testing.
  • PHP 8.2+ Dependency: May block adoption for legacy Laravel projects (pre-8.2). Workaround: Use symplify/monorepo-builder:^11.2 for PHP 8.1.

Key Questions

  1. Dependency Isolation: How will this handle Laravel’s vendor/ symlinks or platform-specific packages (e.g., laravel/framework)?
  2. Release Automation: Can monorepo-builder release integrate with Laravel’s composer.json hooks (e.g., post-update-cmd) for seamless deployments?
  3. Testing Strategy: How to validate merged composer.json files against Laravel’s environment-specific requirements (e.g., APP_ENV)?
  4. Performance: Impact on composer install time when merging hundreds of packages?
  5. Rollback: How to revert a merged composer.json if conflicts arise post-release?

Integration Approach

Stack Fit

  • Primary Use Case: Laravel projects with:
    • Multiple packages (e.g., packages/auth, packages/api).
    • Shared dependencies across packages (e.g., guzzlehttp/guzzle).
    • Need for centralized version management (e.g., enforcing ^9.0 for all packages).
  • Secondary Use Case: Legacy monolithic Laravel apps being decomposed into a monorepo.
  • Anti-Patterns: Avoid for:
    • Projects with no shared dependencies.
    • Teams resistant to Composer-based workflows.

Migration Path

  1. Assessment Phase:
    • Audit current composer.json files for version conflicts.
    • Identify packages that can be extracted into packages/ (e.g., Laravel plugins).
  2. Scaffold Setup:
    composer require symplify/monorepo-builder --dev
    vendor/bin/monorepo-builder init
    
    • Configure monorepo-builder.php to exclude Laravel-specific keys (e.g., extra.laravel).
  3. Incremental Migration:
    • Start with non-critical packages (e.g., utilities).
    • Use merge --dry-run to validate changes.
  4. CI/CD Integration:
    • Add monorepo-builder merge to pre-commit hooks or CI pipelines.
    • Example GitHub Actions step:
      - name: Merge monorepo dependencies
        run: vendor/bin/monorepo-builder merge
      
  5. Release Workflow:
    • Replace manual composer update with monorepo-builder release.

Compatibility

  • Laravel-Specific:
    • Pros: Works with Laravel’s Composer scripts (e.g., post-autoload-dump).
    • Cons: May require custom scripts to handle Laravel’s bootstrap/cache or storage/ paths.
  • Tooling:
    • Compatible with Laravel Forge/Denv for deployment (if composer.json is merged correctly).
    • May conflict with tools like Laravel Envoy if they assume a flat structure.

Sequencing

  1. Phase 1: Initialize monorepo structure (init).
  2. Phase 2: Migrate 1–2 packages to packages/ and test merge.
  3. Phase 3: Automate merge in CI/CD.
  4. Phase 4: Adopt release for coordinated package updates.
  5. Phase 5: Deprecate legacy monolithic composer.json files.

Operational Impact

Maintenance

  • Pros:
    • Single Source of Truth: Root composer.json reduces duplication.
    • Atomic Updates: release command ensures version consistency across packages.
  • Cons:
    • Configuration Drift: monorepo-builder.php requires updates if package structures change.
    • Debugging Complexity: Conflicts in merged files may obscure root causes (e.g., circular dependencies).

Support

  • Learning Curve:
    • Moderate for PHP/Composer-savvy teams; steep for those unfamiliar with monorepos.
    • Requires documentation for Laravel-specific edge cases (e.g., handling APP_KEY in merged configs).
  • Troubleshooting:
    • Use --verbose flags for commands to diagnose merge issues.
    • Leverage Symplify’s issue tracker for PHP-specific problems.

Scaling

  • Performance:
    • Merge: Linear complexity (O(n)) where n = number of packages. Test with 50+ packages to validate.
    • Release: May slow down CI pipelines if running composer validate on merged files.
  • Resource Usage:
    • Memory-intensive for large monorepos (e.g., 100+ packages). Monitor during merge.
  • Horizontal Scaling:
    • Not applicable; tool operates locally or in CI. Parallelize package builds separately.

Failure Modes

Failure Scenario Impact Mitigation
Corrupted merged composer.json Broken dependencies Use merge --dry-run and validate with composer validate.
Version conflict in merge Build failures Configure monorepo-builder.php to enforce strict versions.
CI pipeline timeout Blocked releases Cache Composer dependencies or split merge into smaller batches.
Laravel-specific config loss Missing APP_ENV or .env keys Exclude Laravel-specific keys from merge or use post-merge scripts.
Package namespace collisions Autoloader errors Scope namespaces (e.g., Vendor\Package\*).

Ramp-Up

  • Onboarding:
    • Developers: 1–2 hours to understand merge/release workflows.
    • Ops: 4–8 hours to integrate into CI/CD (e.g., GitHub Actions).
  • Training:
    • Focus on:
      • monorepo-builder.php configuration.
      • Handling Laravel-specific composer.json keys.
      • Debugging merge conflicts.
  • Metrics to Track:
    • Time to first successful merge.
    • Reduction in duplicate composer.json files.
    • CI pipeline duration post-integration.
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.
apiboxsym/user-bundle
apiboxsym/health-check-bundle
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