- Can I use symplify/monorepo-builder to manage a Laravel monorepo with shared packages like auth and API clients?
- Yes, this tool is perfect for Laravel monorepos. It merges package-level `composer.json` files into a root `composer.json`, ensuring consistent dependency versions across shared libraries (e.g., `packages/auth`, `packages/api-clients`). Configure `monorepo-builder.php` to point to your Laravel package directories, like `./packages/` or `./app/Packages/`.
- How do I install symplify/monorepo-builder in a Laravel project?
- Run `composer require symplify/monorepo-builder --dev` in your Laravel project root. Ensure PHP 8.2+ is installed, as older versions are no longer maintained. The tool integrates directly with Composer, requiring no Laravel-specific setup beyond configuring `monorepo-builder.php`.
- Will this tool work with Laravel’s autoloading for packages inside a monorepo?
- Absolutely. The tool handles PSR-4 autoloading for both root and package-level classes, which aligns with Laravel’s namespace resolution. If you’re using symlinked path repos, configure `disableAutoloadMerge()` in `monorepo-builder.php` to avoid conflicts. For Laravel-specific packages, ensure `autoload` entries in package `composer.json` match their namespace paths.
- How do I validate shared dependency versions across Laravel packages in the monorepo?
- Use the `validate` command (`vendor/bin/monorepo-builder validate`) to check for version mismatches in shared dependencies (e.g., `laravel/framework`, `guzzlehttp/guzzle`). This catches conflicts early, ensuring all packages use compatible versions. Run it in CI or as a pre-commit hook for automated checks.
- Can I automate Laravel-specific tasks like cache clearing during a monorepo release?
- Yes, customize the `release` command in `monorepo-builder.php` to include Laravel-specific steps. For example, add a `post-release` script to run `php artisan cache:clear` or `php artisan config:publish`. Test with `release --dry-run` in CI before deploying to production.
- What’s the difference between `merge` and `propagate` in a Laravel monorepo context?
- `merge` combines all package `composer.json` files into the root `composer.json`, centralizing dependency management for the entire monorepo. `propagate` does the reverse: it updates package-level `composer.json` files with versions from the root, ensuring consistency. Use `merge` for development and `propagate` before releases to sync versions.
- How do I handle Laravel service providers or publishable assets in monorepo packages?
- For service providers, register them in the root `config/app.php` under the `providers` array. For publishable assets (e.g., config files, migrations), ensure the package’s `composer.json` targets the root `config/` or `public/` directories using the `extra.publish` field. The `merge` command will propagate these settings to the root `composer.json`.
- Is symplify/monorepo-builder compatible with Laravel Forge or Envoyer for deployments?
- Yes, the tool integrates seamlessly with Forge/Envoyer. Use the `release` command to trigger version tags, which can then hook into your deployment pipeline. For Envoyer, configure a recipe to run `composer install` and `php artisan migrate` after the release tag is pushed. Test the workflow with `release --dry-run` first.
- How do I test individual Laravel packages in isolation within a monorepo?
- Use the `localize-composer-paths` feature in your CI or testing environment to symlink package dependencies locally. For Laravel packages, run tests with `php artisan test` from the root, but ensure your `phpunit.xml` includes the package’s namespace. Alternatively, use Pest with `--testsuite` to target specific packages.
- What are the Laravel version and PHP requirements for symplify/monorepo-builder?
- The tool requires PHP 8.2+ and is compatible with Laravel 10+. For PHP 8.1, use version `^11.2` (though it’s no longer maintained). Laravel’s Composer-based workflows ensure smooth integration, but avoid using `replace` for packages that rely on Laravel’s published assets (e.g., Breeze or Vapor).