Download the PHP package php-core/composer-git-hooks without Composer

On this page you can find all versions of the php package php-core/composer-git-hooks. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package composer-git-hooks

composer-git-hooks

this is a fork of the original package (by BrainMaestro)

Packagist Download

Manage git hooks easily in your composer configuration. This command line tool makes it easy to implement a consistent project-wide usage of git hooks. Specifying hooks in the composer file makes them available for every member of the project team. This provides a consistent environment and behavior for everyone which is great. It is also possible to use to manage git hooks globally for every repository on your computer. That way you have a reliable set of hooks crafted by yourself for every project you choose to work on.

Install

Add a hooks section to the extra section of your composer.json and add the hooks there.

Then install with

This installs the cghooks binary to your vendor/bin folder. If this folder is not in your path, you will need to preface every command with vendor/bin/.

Note: hooks declared in the scripts or hooks root sections of composer.json are no longer supported in v3.

Global support

You can also install it globally. This feels much more natural when cghooks is used with the newly added support for managing global git hooks.

All commands have global support (besides testing the hooks. Still requires being in the directory with the composer.json file).

Optional Configuration

Stop on failure

When a hook is a sequence of commands, it can be useful to stop the execution when a command fails.

Specify the impacted hooks in the stop-on-failure config section.

Always be sure to run the update command after changing the stop-on-failure config section.

Custom hooks

Custom hooks can be added to the custom-hooks array of the `config section.

Always be sure to run the update command after changing the custom-hooks config section. Note: config is not valid custom hook value.

Shortcut

Add a cghooks script to the scripts section of your composer.json file. That way, commands can be run with composer cghooks ${command}. This is ideal if you would rather not edit your system path.

Composer Events

Add the following events to your composer.json file. The cghooks commands will be run every time the events occur. Go to Composer Command Events for more details about composer's event system.

Usage

All the following commands have to be run either in the same folder as your composer.json file or by specifying the --git-dir option to point to a folder with a composer.json file.

Adding Hooks

After installation is complete, run cghooks add to add all the valid git hooks that have been specified in the composer config.

Option Description Command
no-lock Do not create a lock file cghooks add --no-lock
ignore-lock Add the lock file to .gitignore cghooks add --ignore-lock
force-win Force windows bash compatibility cghooks add --force-win

The lock file contains a list of all added hooks.

If the --global flag is used, the hooks will be added globally, and the global git config will also be modified. If no directory is provided, there is a fallback to the current core.hooksPath in the global config. If that value is not set, it defaults to $COMPOSER_HOME (this specific fallback only happens for the add command). It will fail with an error if there is still no path after the fallbacks.

Updating Hooks

The update command which is run with cghooks update basically ignores the lock file and tries to add hooks from the composer file. This is similar to what the --force option for the add command did. This command is useful if the hooks in the composer.json file have changed since the first time the hooks were added.

This works similarly when used with --global except that there is no fallback to $COMPOSER_HOME if no directory is provided.

Removing Hooks

Hooks can be easily removed with cghooks remove. This will remove all the hooks that were specified in the composer config.

Hooks can also be removed by passing them as arguments. The command cghooks remove pre-commit post-commit which will remove the pre-commit and post-commit hooks.

Option Description Command
force Delete hooks without checking the lock file cghooks remove --force

CAREFUL: If the lock file was tampered with or the force option was used, hooks that already existed before using this package, but were specified in the composer scripts config will be removed as well. That is, if you had a previous pre-commit hook, but your current composer config also has a pre-commit hook, this option will cause the command to remove your initial hook.

This also does not have a fallback to $COMPOSER_HOME if no directory is provided when used with --global.

Listing hooks

Hooks can be listed with the cghooks list-hooks command. This basically checks composer config and list the hooks that actually have files.

Common Options

The following options are common to all commands.

Option Description Command
git-dir Path to git directory cghooks ${command} --git-dir='/path/to/.git'
lock-dir Path to lock file directory cghooks ${command} --lock-dir='/path/to/lock'
global Runs the specified command globally cghooks ${command} --global

Each command also has a flag -v to control verbosity for more detailed logs. Currently, only one level is supported.

Testing Hooks

Hooks can be tested with cghooks ${hook} before adding them. Example cghooks pre-commit runs the pre-commit hook.

Contributing

Please see CONTRIBUTING for details.

Credits

Related

License

The MIT License (MIT). Please see License File for more information.


All versions of composer-git-hooks with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
symfony/console Version ^5.0|^6.0|^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package php-core/composer-git-hooks contains the following files

Loading the files please wait ....