Skip to content

GitHooksManager ​

php
final readonly class Zairakai\LaravelDevTools\Services\GitHooksManager

Manages installation of git hooks into a versioned .githooks/ directory.

Strategy: hooks are copied (not symlinked) into .githooks/ at the project root. Git is configured via git config core.hooksPath .githooks so the hooks are active immediately without any per-developer action.

Advantages of .githooks/ over .git/hooks/:

  • Versionable: hooks are committed with the project
  • Inspectable and editable directly in the project tree
  • Shared automatically with all team members on clone

Source: src/Services/GitHooksManager.php

Methods ​

__construct() ​

php
public function __construct(Command $command, Factory $componentsFactory)

publishGitHooks() ​

php
public function publishGitHooks(string $stubsPath, string $basePath, bool $force, bool $withHooks): void

Copy git hooks stubs into .githooks/ and configure git to use them.

ParameterDescription
$stubsPathAbsolute path to the vendor stubs directory
$basePathAbsolute path to the project root
$forceOverwrite existing hooks if true
$withHooksWhether hooks should actually be installed

Documentation of 4.3.0 , built from 0bcdf31 on 4.3.0 by pipeline #2936310886 on 2026-10-11.