- How do I install this package for a Laravel project?
- Run `composer require brainmaestro/composer-git-hooks` in your Laravel project directory. The package integrates as a Composer plugin, so no additional Laravel service provider or configuration is needed beyond the composer.json setup.
- Which Laravel versions does this package support?
- This package works with any Laravel version since it operates at the Composer level, not the framework level. It’s compatible with Laravel 5.8+ and newer, as long as your project uses Composer for dependency management.
- Can I migrate existing Git hooks to this system?
- Yes, you can manually define your existing hooks in the `extra.composer-git-hooks` section of your `composer.json`. The package will then manage them alongside your Composer dependencies, ensuring they’re version-controlled and reproducible across environments.
- Does this work with CI/CD pipelines like GitHub Actions or GitLab CI?
- Absolutely. Since hooks are defined in `composer.json`, they’ll run consistently in CI/CD pipelines when `composer install` or `composer update` is executed, enforcing your workflow rules in automated environments.
- What if I need custom hooks beyond pre-commit or pre-push?
- The package supports all standard Git hooks (e.g., `pre-receive`, `post-merge`, `prepare-commit-msg`). You can define them in `composer.json` under `extra.composer-git-hooks` with their respective script paths or commands.
- Will this slow down `composer install` in Laravel?
- Minimal impact. Hooks are only executed when explicitly triggered (e.g., `composer hooks:run`), not during every `composer install`. For Laravel projects, this is ideal—hooks run only when needed, like during development or CI checks.
- How do I enforce hooks for the entire team?
- Since hooks are versioned in `composer.json`, every team member gets the same hooks when they run `composer install`. This ensures consistency across all environments, from local dev to production staging.
- Are there alternatives to this package for Laravel?
- Yes, alternatives include `evilmartians/composer-hooks` or manual Git hook scripts. However, this package stands out by integrating natively with Composer, making it easier to manage hooks alongside Laravel’s dependency workflow.
- Can I test hooks locally before committing to the project?
- Yes, run `composer hooks:run [hook-name]` to test a specific hook locally. This is useful for debugging or verifying hooks work as expected before they’re committed to `composer.json`.
- What happens if a hook fails in production?
- Hook failures in production depend on your setup. For critical hooks (e.g., `pre-push`), you can configure them to exit with errors, blocking the Git operation. For non-critical hooks, log failures and continue to avoid disrupting deployments.