All Projects → felipebool → crook

felipebool / crook

Licence: MIT License
Simple hook management tool made with PHP

Programming Languages

PHP
23972 projects - #3 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to crook

Private Composer Installer
Composer install helper outsourcing sensitive keys from the package URL into environment variables
Stars: ✭ 168 (+180%)
Mutual labels:  packagist, composer
packagist
🐳 Dockette out-of-box Packagist (Nginx / Solr 6 / PHP 7.1+FPM)
Stars: ✭ 32 (-46.67%)
Mutual labels:  packagist, composer
Asset Packagist
Asset Packagist
Stars: ✭ 235 (+291.67%)
Mutual labels:  packagist, composer
Ansible Role Composer
Ansible Role - Composer PHP Dependency Manager
Stars: ✭ 149 (+148.33%)
Mutual labels:  packagist, composer
composer-diff
Compares composer.lock changes and generates Markdown report so you can use it in PR description.
Stars: ✭ 51 (-15%)
Mutual labels:  packagist, composer
Hprose Php
Hprose is a cross-language RPC. This project is Hprose 3.0 for PHP
Stars: ✭ 1,952 (+3153.33%)
Mutual labels:  packagist, composer
generator-composer
🐘 Yeoman (http://yeoman.io) generator for a PHP Composer project
Stars: ✭ 16 (-73.33%)
Mutual labels:  packagist, composer
Satis Server
🐳 Private, self-hosted Composer/Satis repository with unlimited private and open-source packages and support for Git, Mercurial, and Subversion. HTTP API, HTTPs support, webhook handler, scheduled builds, Slack and HipChat integration.
Stars: ✭ 96 (+60%)
Mutual labels:  packagist, composer
ip
Immutable value object for IPv4 and IPv6 addresses, including helper methods and Doctrine support.
Stars: ✭ 212 (+253.33%)
Mutual labels:  packagist, composer
private-packagist-api-client
Private Packagist API Client
Stars: ✭ 28 (-53.33%)
Mutual labels:  packagist, composer
Laravel Paket
Composer GUI. Manage Laravel dependencies from web interface without switching to command line!
Stars: ✭ 143 (+138.33%)
Mutual labels:  packagist, composer
alfred-packagist
Alfred workflow to search for PHP packages with Packagist
Stars: ✭ 21 (-65%)
Mutual labels:  packagist, composer
Security Advisories
A database of PHP security advisories
Stars: ✭ 1,740 (+2800%)
Mutual labels:  packagist, composer
hooks4git
Extensible Hook Management System for GIT
Stars: ✭ 27 (-55%)
Mutual labels:  hooks, githook
Packeton
📦 Private, self-hosted Packagist/Composer/Satis repository with unlimited private repos.
Stars: ✭ 115 (+91.67%)
Mutual labels:  packagist, composer
Satis
Simple static Composer repository generator - For a full private Composer repo use Private Packagist
Stars: ✭ 2,722 (+4436.67%)
Mutual labels:  packagist, composer
Packagist Mirror
Alibaba Cloud Packagist Mirror
Stars: ✭ 63 (+5%)
Mutual labels:  packagist, composer
Keygen Php
A fluent PHP random key generator.
Stars: ✭ 93 (+55%)
Mutual labels:  packagist, composer
composer-localdev-plugin
Composer Plugin for local development
Stars: ✭ 31 (-48.33%)
Mutual labels:  packagist, composer
composer-velocita
Velocita - Composer plugin for transparent caching
Stars: ✭ 26 (-56.67%)
Mutual labels:  packagist, composer

Build Status Maintainability Codacy Badge Codacy Badge

Crook

First of all, Crook is a work in progress.

If you are not familiar with git hooks, you may want to read Git Hooks documentation first.

Crook is the simplest way to define and manage your Git Hooks. Its aim is to allow scripts from your composer.json run when git hook actions are triggered.

Usage

The aim of this project is to be as simple as possible, thus, you won't have to write any PHP code, you just need to install any packages from packagist and then make them run for partucular git hooks. The process is explained in the following sections.

Installation

Just run

$ composer require felipebool/crook --dev

Init Crook

$ vendor/bin/crook init will create crook.json configuration file and theHook in the root of your project.

Add a new hook

$ vendor/bin/crook add hook-name action-name will create a symbolic link from .git/hooks/hook-name to theHook, enabling that hook.

Remove a hook

$ vendor/bin/crook remove hook-name will remove the symbolic link .git/hooks/hook-name, disabling that hook.

Add a action to composer.json

When you add a new action using add you need to add what is expected to run when that action is triggered inside you composer.json. To do that, you must create a new entry inside the section scripts and then define what must run there.

Crook configuration file

Crook uses a json configuration file just like composer, it is called crook.json. The configuration is made, basically, by writting as a key the git hook name and as value the respective script entry in composer.json. See the following example

{
  "pre-commit": "code-check",
  "composer": "/home/felipe/bin/composer"
}

Although you are able to edit crook.json by yourself, you should do it using $ vendor/bin/crook in order to create the symbolic links. Only the composer path must be set manually. The mechanism is explained in the next section.

The mechanism

Every time you run a vendor/bin/crook add hook-name action-name Crook creates a symbolic link from .git/hooks/hook-name to /your/project/hook/theHook, simple as that.

Now, when git trigger the action hook-name, it will follow the link to /your/project/hook/theHook and Crook will then look for a script named action-name inside your project's composer.json and will execute the commands defined there.

Adding code validation using phpcs before any commit

In order to check your code against PSR2, you must do this

Add the script action inside composer.json

"scripts": {
  "code-check": "phpcs --standard=PSR2 src/",
}

Initialize crook

$ vendor/bin/crook init

Bind code-check to pre-commit hook

$ vendor/bin/crook add pre-commit code-check

Next time you run $ git commit -m 'some message' crook will run the code defined inside code-check and will prevent code from being commited if the check fail.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].