All Projects → php-composter → Php Composter

php-composter / Php Composter

Git Hooks Management through Composer

Projects that are alternatives of or similar to Php Composter

Frontend
🍭 Frontend for Home Assistant
Stars: ✭ 1,366 (+1239.22%)
Mutual labels:  hacktoberfest
Os Autoinst
OS-level test automation
Stars: ✭ 99 (-2.94%)
Mutual labels:  hacktoberfest
Beanmother
A library for setting up Java objects as test data.
Stars: ✭ 102 (+0%)
Mutual labels:  hacktoberfest
Matchimals.fun
🦁 🃏 📱 An animal matching puzzle card game– built with turn-based game engine boardgame.io and React-Native + React-Native-Web
Stars: ✭ 101 (-0.98%)
Mutual labels:  hacktoberfest
Opensource
Conheça os projetos Open Source na Globo.com
Stars: ✭ 100 (-1.96%)
Mutual labels:  hacktoberfest
Nothing Private
Do you think you are safe using private browsing or incognito mode?. 😄 👿 This will prove that you're wrong.
Stars: ✭ 1,375 (+1248.04%)
Mutual labels:  hacktoberfest
Pytest Recording
A pytest plugin that allows recording network interactions via VCR.py
Stars: ✭ 98 (-3.92%)
Mutual labels:  hacktoberfest
Ex gram
Telegram Bot API low level API and framework
Stars: ✭ 103 (+0.98%)
Mutual labels:  hacktoberfest
Runit
Development repository for the Chef Runit Cookbook
Stars: ✭ 101 (-0.98%)
Mutual labels:  hacktoberfest
Lychee
The most complete and powerful data-binding library and persistence infra for Kotlin 1.3, Android & Splitties Views DSL, JavaFX & TornadoFX, JSON, JDBC & SQLite, SharedPreferences.
Stars: ✭ 102 (+0%)
Mutual labels:  hacktoberfest
Elasticsearch Analysis Openkoreantext
Korean analysis plugin that integrates open-korean-text module into elasticsearch.
Stars: ✭ 101 (-0.98%)
Mutual labels:  hacktoberfest
Starter Plugin
A lean WordPress plugin boilerplate, ready for your next project.
Stars: ✭ 101 (-0.98%)
Mutual labels:  hacktoberfest
River pod
A simple way to access state while robust and testable.
Stars: ✭ 1,366 (+1239.22%)
Mutual labels:  hacktoberfest
Yii2 Starter Kit
Yii2 Starter Kit
Stars: ✭ 1,372 (+1245.1%)
Mutual labels:  hacktoberfest
Tabfern
Google Chrome extension for saving and restoring sets of tabs, and for switching between windows and tabs from a vertical, grouped list.
Stars: ✭ 102 (+0%)
Mutual labels:  hacktoberfest
Asf Ui
The official web interface for ASF
Stars: ✭ 100 (-1.96%)
Mutual labels:  hacktoberfest
Insideheartz Whatsapp Bot
A multipurpose whatsapp bot buillt on node.js
Stars: ✭ 102 (+0%)
Mutual labels:  hacktoberfest
Circe Yaml
YAML parser for circe using SnakeYAML
Stars: ✭ 102 (+0%)
Mutual labels:  hacktoberfest
Swagger Combine
Combines multiple Swagger schemas into one dereferenced schema.
Stars: ✭ 102 (+0%)
Mutual labels:  hacktoberfest
React Ladies
We're a group of women and non-binary ReactJS enthusiasts in New York City (and beyond).
Stars: ✭ 102 (+0%)
Mutual labels:  hacktoberfest

Bright Nucleus PHP Composter

Git Hooks Management through Composer.

Latest Stable Version Total Downloads Latest Unstable Version License

This is a Composer plugin that manages Git pre- & post-hooks through Composer dependencies. Actions you want to be executed on Git hooks can simply be required as --dev dependencies, and will immediately become active on composer install.

Introductory post: Adding Git Hooks Through Composer Dev-Dependencies

Table Of Contents

Installation

You should not need to install this package directly. It should come as a dependency of a package that is of type php-composter-action.

Existing PHP Composter Actions

  • PHP Composter PHPCS PSR2

    Check your PHP source code for PSR-2 compliance before committing.

  • PHP Composter Regular Expression

    Check your commit messages against a regular expression pattern, to enforce a commit message standard.

  • PHP Composter PHPCS WordPress

    Check your PHP source code for WordPress Coding Standards compliance before committing.

    Thanks to Gabor Javorszky for contributing this action.

  • PHP Composter PHPCS Drupal

    Check your source code for Drupal Coding Standards compliance before committing.

    Action by Nick Wilde.

  • PHP Composter PHPUnit (coming soon)

    Run a PHPUnit test suite before committing.

  • PHP Composter PHP Syntax Checker (coming soon)

    Validate the PHP syntax before committing.

Creating a New PHP Composter Action

To build a new PHP Composter action, you need to proceed as follows:

  1. Create a Composer Package with a Valid Name
  2. Extend BaseAction class
  3. Add Public Methods
  4. Add the Class to Composer Autoloader
  5. Set the Composer Package Type to php-composter-action
  6. Add php-composter/php-composter as a dependency
  7. Configure Git Hooks through Composer Extra key

Create a Composer Package with a Valid Name

Create a new Composer package with the following naming pattern: <vendor>/php-composter-<action intent>

Example:

composer init --name php-composter/php-composter-example

Extend BaseAction class

Create a new class that extends PHPComposter\PHPComposter\BaseAction.

Example:

<?php namespace PHPComposter\PHPComposterExample;

use PHPComposter\PHPComposter\BaseAction;

class Example extends BaseAction
{
    // [...]
}

Add Public Methods

PHP Composter allows you to attach PHP methods to Git hooks. These methods need to be publicly accessible, so that they can be called by the PHP-Composter bootstrapping script.

Example:

<?php
// [...]

class Example extends BaseAction
{

    /**
     * Example pre-commit action method.
     *
     * @var string $hook Name of the hook that was triggered.
     * @var string $root Root folder in which the hook was triggered.
     */
    public function preCommit()
    {
        echo 'Example Pre-Commit Hook ' . $this->hook . ' @ ' . $this->root . PHP_EOL;
    }
}

Set the Composer Package Type to php-composter-action

You need to set the type of your Composer package in your composer.json file to php-composter-action.

Example:

{
  "name": "php-composter/php-composter-example",
  "description": "PHP Composter Example.",
  "type": "php-composter-action",
  "[...]": ""
}

Add the Class to Composer Autoloader

Composer's Autoloader will be initialized for each Git hook, so make sure you've registered your newly created class correctly.

Example:

{
  "[...]": "",
  "autoload": {
    "psr-4": {
      "PHPComposter\\PHPComposterExample\\": "src/"
    }
  },
  "[...]": ""
}

Add php-composter/php-composter as a dependency

You need to set the type of your Composer package in your composer.json file to php-composter-action.

Example:

{
  "[...]": "",
  "require": {
    "php-composter/php-composter": "^0.1",
  },
  "[...]": ""
}

Configure Git Hooks through Composer Extra key

Finally, add a new entry "php-composter-hooks" to the extra key in the package's composer.json to attach each of your methods to a specific Git hook.

Example:

{
  "[...]": "",
  "extra": {
    "php-composter-hooks": {
      "20.pre-commit": "PHPComposter\\PHPComposterExample\\Example::preCommit"
    }
  }
}

Hooks can either be "<priority>.<git-hook-name>", or just "<git-hook-name>".

In the above example, the priority is 20. It defaults to 10 if omitted. Lower priority numbers get executed before higher ones.

Supported Git Hooks:

  • applypatch-msg
  • pre-applypatch
  • post-applypatch
  • pre-commit
  • prepare-commit-msg
  • commit-msg
  • post-commit
  • pre-rebase
  • post-checkout
  • post-merge
  • post-update
  • pre-auto-gc
  • post-rewrite
  • pre-push

Using Existing PHP Composter Actions in Your Projects

To use an existing PHP Composter Action in your projects, simply require them as --dev dependencies:

composer require --dev php-composter/php-composter-example

Anyone using Composer to pull in the development dependencies will automatically have your PHP Composter Actions installed into their .git.

Skipping Installation of PHP Composter Actions

In case you want to install your the Composer dependencies of a project without activating the PHP Composter system, you can run Composer with the --no-plugins option:

composer install --no-plugins

Contributing

All feedback / bug reports / pull requests are welcome.

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].