- How does composer/installers help with Laravel asset management?
- It automates the placement of package assets (e.g., JS/CSS in `public/`, configs in `config/`) during `composer install` or `update`, eliminating manual `php artisan` commands like `storage:link` or `config:cache`. This is especially useful in CI/CD pipelines where you want to avoid repetitive steps.
- Can I use this package with Laravel 5.5 or older versions?
- The package officially supports Laravel 5.5+, but older versions may require additional dependencies like `composer/semver`. Test thoroughly in your environment, as some Laravel-specific optimizations (e.g., `post-install-cmd` hooks) might not work as expected.
- What’s the difference between `installer-paths` and custom Composer scripts?
- `installer-paths` defines where assets should go (e.g., `public/{$name}`), while custom Composer scripts (like `post-install-cmd`) trigger actions. This package replaces manual scripts for asset linking, reducing boilerplate. However, you can still use scripts for other tasks.
- Will this break existing `php artisan` commands in my CI/CD pipeline?
- No, it’s designed to *replace* repetitive `artisan` commands (e.g., `storage:link`) with automated Composer steps. Audit your pipeline first—remove redundant commands after testing. Conflicts can arise if both the installer and your scripts try to modify the same directories.
- How do I configure custom paths for non-standard Laravel directory structures?
- Use the `installer-paths` key in `composer.json` to define custom mappings, like `"extra": {"installer-paths": {"app/Resources/{$name}": ["type:resource"]}}`. This is useful for monorepos or projects with non-default structures, but test thoroughly to avoid broken asset links.
- Does this package work with Symfony or other non-Laravel PHP frameworks?
- Yes, it’s framework-agnostic. You can define custom `installer-paths` for any project, but Laravel-specific optimizations (like `post-install-cmd` hooks) won’t apply. It’s ideal for Symfony or custom frameworks needing automated asset installation.
- How do I handle environment-specific asset paths (e.g., `public/staging/` vs. `public/prod/`)?
- The package doesn’t natively support environment-specific paths, but you can use Composer’s `post-install-cmd` scripts to symlink or move assets post-install. Alternatively, configure paths dynamically via environment variables in your `installer-paths` definitions.
- Are there performance concerns with adding this to my Composer workflow?
- The overhead is minimal—it runs during `composer install`/`update` like any other post-install script. Benchmark with `composer install --profile` to measure impact. If you’re already using `php artisan` commands, the trade-off is usually worth it for automation.
- What if I have conflicting `post-install-cmd` scripts (e.g., from Laravel Forge or Envoyer)?
- Order matters. Explicitly define the sequence in `composer.json` under `scripts`. Place `composer/installers` early if it’s a dependency, or late if it should run after other scripts. Test in CI to ensure no race conditions.
- Is there a way to use this without modifying `composer.json` globally?
- Yes, you can scope configurations to specific packages using `extra.installer-paths` per-package. For example, a package’s `composer.json` can define its own paths, and the installer will respect them during installation. This is useful for libraries or plugins.