Skip to content

Upgrading from 3.x to 4.0

GitHooks is called Alfil from 4.0. Same tool, same configuration shape (hooks / flows / jobs); what changes is the package, the binary and a handful of names. Most projects upgrade with four commands.

Still on a v2 configuration?

If your configuration uses Options / Tools, a githooks.yml or camelCase job keys, 4.0 will not read it. Follow Upgrading from v2 first.

The upgrade

composer remove --dev wtyd/githooks
composer require --dev wtyd/alfil
vendor/bin/alfil hook          # regenerate .githooks/ — the 3.x scripts call a binary that no longer exists
vendor/bin/alfil conf:check    # reports anything still named the 3.x way

Run vendor/bin/alfil hook before your next commit. The scripts in .githooks/ were generated by 3.x and call php vendor/bin/githooks, which disappears with the old package: until they are regenerated, every commit fails. alfil status lists any script that still calls the old binary. If your configuration sets hooks.command to the old binary (for example php7.4 vendor/bin/githooks), point it at vendor/bin/alfil first — conf:check warns about it.

What changes

3.x 4.0 Notes
wtyd/githooks wtyd/alfil wtyd/githooks is abandoned in favour of wtyd/alfil.
vendor/bin/githooks vendor/bin/alfil No alias: regenerate the hooks (above) and update CI scripts, composer.json scripts and docs that call the old binary.
githooks.php / githooks.local.php alfil.php / alfil.local.php The old names still work until 5.0, with a config-file-rename deprecation. Rename both together: the override pairs with the main file by name.
$GITHOOKS_BRANCH $ALFIL_BRANCH The old variable is still read until 5.0 when the new one is unset, with an env-var-rename deprecation.
Wtyd\GitHooks\Utils\ComposerUpdater::phpOldVersions Wtyd\Alfil\Utils\ComposerUpdater::phpOldVersions Only for PHP 7.4/8.0 projects that call it from composer.json scripts. The old class name keeps working until 5.0.
JSON runtime.githooksVersion runtime.alfilVersion Both are emitted until 5.0, with the same value.
SARIF tool.driver.name: githooks alfil GitHub Code Scanning tracks alerts by tool name: existing alerts close and reopen once under the new name.
GitLab CI sections githooks_job_N / githooks_summary alfil_job_N / alfil_summary Only matters if you link to section ids.
.githooks/ .githooks/ Unchanged: it is just the core.hooksPath directory.

Everything the 3.x line had marked "removed in v4.0" (tool, YAML, Options / Tools, camelCase keys, conf:migrate) is gone as well; see the changelog.

Composer scripts

If your composer.json reinstalls the hooks or copies the PHP 7.4 binary on install, update the names:

"scripts": {
    "post-install-cmd": ["Wtyd\\Alfil\\Utils\\ComposerUpdater::phpOldVersions", "vendor/bin/alfil hook"],
    "post-update-cmd": ["Wtyd\\Alfil\\Utils\\ComposerUpdater::phpOldVersions", "vendor/bin/alfil hook"]
}

The ComposerUpdater entries are only needed on PHP 7.4 / 8.0. See Installation.