- How does this package differ from manually writing `post-install-cmd` scripts in `composer.json`?
- This package provides a structured, reusable way to define file actions (copy, create, symlink, remove) scoped to specific packages, rather than global Composer scripts. It avoids cluttering your `composer.json` and centralizes logic in the package itself, making it easier to maintain and version-control.
- Can I use this for Laravel-specific tasks like generating config files or running migrations on first install?
- Yes, but with limitations. The package handles file operations (e.g., copying config stubs or creating directories), but migrations or database seeding would require additional Laravel-specific logic post-install. You’d typically combine this with Laravel’s `booted` event or service providers for runtime tasks.
- Does this work with Laravel’s asset compilation (Mix/Vite) or should I handle that separately?
- This package is designed for pre-install/update file operations, so it won’t trigger asset compilation. Use it to copy vendor assets to `public/` or `resources/` before Laravel’s build tools run. For example, copy a package’s JS/CSS files to your project’s assets folder during install.
- What Laravel versions does this package support, and are there any PHP version requirements?
- The package is PHP/Composer-agnostic, so it works with any Laravel version (5.8+) as long as your project uses Composer. However, file permissions (e.g., `chmod 777`) may behave differently across shared hosting or Windows environments. Test thoroughly in your target deployment setup.
- How do I conditionally execute actions (e.g., only in local dev or for specific environments)?
- The package doesn’t natively support environment-based conditions, but you can work around this by using Laravel’s `app()` container or environment variables in a post-install script. For example, check `APP_ENV` in a `post-package-install` script triggered by the plugin’s actions.
- What happens if the package’s actions fail during deployment (e.g., permission denied)?
- The package will throw errors during Composer’s lifecycle events, which may halt installation. To mitigate this, ensure proper file permissions in your deployment pipeline (e.g., use `chmod` in CI/CD) or wrap actions in error-handling logic within your package’s `post-install-cmd`.
- Are there alternatives to this package for Laravel-specific file operations?
- For Laravel, consider `spatie/laravel-package-tools` (for config publishing) or custom `composer.json` scripts. This package excels at Composer-native file ops but lacks Laravel’s runtime integration. If you need both install-time and runtime logic, combine this with Laravel’s service providers or console commands.
- Can I extend or customize the package’s behavior without forking it?
- The package is designed to be used via `composer.json` configuration, so customization is limited to defining actions in the `extra` section. For advanced use cases (e.g., dynamic paths or conditional logic), you’d need to create a custom Composer plugin or extend the package’s source code.
- How do I test this package in a CI/CD pipeline (e.g., GitHub Actions) before production?
- Run `composer install --prefer-dist` in your CI pipeline to trigger the package’s actions. Mock file operations by checking for created/symlinked files in your tests. For Laravel, use `Artisan::call()` to simulate post-install tasks if needed, but focus on verifying file structures and permissions.
- Is this package actively maintained, and what are the risks of using it?
- As of now, the package has no visible maintenance or community adoption, which introduces risks like undocumented behavior or breaking changes. Always review the source code for critical operations (e.g., file deletions) and consider forking it if you rely on its functionality long-term.