Appearance
GitHooksManager
php
final readonly class Zairakai\LaravelDevTools\Services\GitHooksManagerManages 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): voidCopy git hooks stubs into .githooks/ and configure git to use them.
| Parameter | Description |
|---|---|
$stubsPath | Absolute path to the vendor stubs directory |
$basePath | Absolute path to the project root |
$force | Overwrite existing hooks if true |
$withHooks | Whether hooks should actually be installed |