• Stars
    star
    177
  • Rank 215,985 (Top 5 %)
  • Language
    Shell
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pre-commit scripts appropriate for any PHP project. These hooks are made as custom plugins under the pre-commit git hook framework.

Hootsuite - PHP Pre-commit Hooks

Pre-commit scripts appropiate for any PHP project. These hooks are made as custom plugins under the pre-commit git hook framework.

Setup

Just add to your .pre-commit-config.yaml file with the following

- repo: [email protected]:hootsuite/pre-commit-php.git
  sha: 1.1.0
  hooks:
  - id: php-lint
  - id: php-unit
  - id: php-cs
    files: \.(php)$
    args: [--standard=PSR1 -p]
  - id: php-cbf
    files: \.(php)$
    args: [--standard=PSR1 -p]

Supported Hooks

php-lint

<<<<<<< HEAD
- repo: [email protected]:hootsuite/pre-commit-php.git
  sha: 1.1.0
  hooks:
  - id: php-lint

A bash script that runs php -l against stage files that are php. Assumes php is a global executable command. Will exit when it hits the first syntax error.

php-lint-all

- repo: [email protected]:hootsuite/pre-commit-php.git
  sha: 1.1.0
  hooks:
  - id: php-lint-all

A systems hook that just runs php -l against stage files that have the .php extension. Add the args: [-s first] in your .pre-commit-config.yaml to enable it to exit on the first error found.

php-unit

- repo: [email protected]:hootsuite/pre-commit-php.git
  sha: 1.1.0
  hooks:
  - id: php-unit

A bash script that will run the appropriate phpunit executable. It will assume

  • Find the executable to run at either vendor/bin/phpunit, phpunit or php phpunit.phar (in that exact order).
  • There is already a phpunit.xml in the root of the repo

Note in its current state, it will run the whole PHPUnit test as along as .php file was committed.

php-cs

- repo: [email protected]:hootsuite/pre-commit-php.git
  sha: 1.1.0
  hooks:
  - id: php-cs
    files: \.(php)$
    args: [--standard=PSR1 -p]

Similar pattern as the php-unit hook. A bash script that will run the appropriate PHP Code Sniffer executable.

It will assume that there is a valid PHP Code Sniffer executable at these locations, vendor/bin/phpcs, phpcs or php phpcs.phar (in that exact order).

The args property in your hook declaration can be used for pass any valid PHP Code Sniffer arguments. In the example above, it will run PHP Code Sniffer against only the staged php files with the PSR-1 and progress enabled.

If you have multiple standards or a comma in your args property, escape the comma character like so

php-cbf

- repo: [email protected]:hootsuite/pre-commit-php.git
  sha: 1.1.0
  hooks:
  - id: php-cs
    files: \.(php)$
    args: [--standard=PSR1 -p]

Similar pattern as the php-cs hook. A bash script that will run the appropriate PHP Code Sniffer executable and will try to fix errors if it can using phpcbf.

It will assume that there is a valid PHP Code Beautifier and Fixer executable at these locations, vendor/bin/phpcbf, phpcbf or php phpcbf.phar (in that exact order).

The args property in your hook declaration can be used for pass any valid PHP Code Sniffer arguments. In the example above, it will run PHP Code Sniffer against only the staged php files with the PSR-1 and progress enabled.

If you have multiple standards or a comma in your args property, escape the comma character like so

- repo: [email protected]:hootsuite/pre-commit-php.git
  sha: 1.1.0
  hooks:
  - id: php-cs
    files: \.(php)$
    args: ["--standard=PSR1/,path/to/ruleset.xml", "-p"]

To install PHP Codesniffer (phpcs & phpcbf), follow the recommended steps here.

php-cs-fixer

- repo: [email protected]:hootsuite/pre-commit-php.git
  sha: 1.1.0
  hooks:
  - id: php-cs-fixer
    files: \.(php)$
    args: [--level=PSR2]

Similar pattern as the php-cs hook. A bash script that will run the appropriate PHP Coding Standards Fixer executable and to fix errors according to the configuration. It accepts all of the args from the php-cs-fixer command, in particular the --level, --config, and --config-file options.

The tool will fail a build when it has made changes to the staged files. This allows a developer to do a git diff and examine the changes that it has made. Remember that you may omit this if needed with a SKIP=php-cs-fixer git commit.

More Repositories

1

grid

Drag and drop library for two-dimensional, resizable and responsive lists
JavaScript
3,572
star
2

atlantis

Atlantis is now being maintained at https://github.com/runatlantis/atlantis
Go
614
star
3

nachos

Material Chips for Android
Java
450
star
4

healthchecks

A go implementation of the Health Checks API used for microservice exploration, documentation and monitoring.
Go
132
star
5

akka-persistence-redis

Akka Persistence that uses Redis as backend
Scala
117
star
6

health-checks-api

Standardize the way services and applications expose their status in a distributed application
API Blueprint
95
star
7

microservice-graph-explorer

Navigate and explore all of the microservices in your application in real time using the real application connections.
JavaScript
74
star
8

sens8

Kubernetes controller for Sensu checks
Go
42
star
9

token-ui

Text input components that allows to add 'tokens' rendered as pills.
Swift
42
star
10

hermes

Kotlin ktor application which bridges Github and Slack. Use it to automate common workflows involving those platforms
Kotlin
35
star
11

scala-circuit-breaker

A circuit breaker for Scala applications and services
Scala
35
star
12

wordpress-multisite-vagrant

JavaScript
27
star
13

sbt-swagger

SBT plugin for extracting Swagger & JAX-RS (jsr311) annotations from compiled classes into Swagger API models, which are then serialized to JSON for consumption with swagger-ui.
Scala
27
star
14

vault-ctrl-tool

Simple tool for managing authentication, secrets, and leases for services.
Go
26
star
15

backup53

AWS Route53 backup tool
Python
23
star
16

hootsuite-app-express

Sample Hootsuite app directory app using Express and Node.js
JavaScript
19
star
17

statsd-client

A lightweight library for generating statsd events from in Scala applications.
Scala
13
star
18

apis-101

Beginners-friendly introduction to APIs starter code.
JavaScript
11
star
19

maintenance-calendar-for-aws

Go
9
star
20

OwlBanners

Swift
7
star
21

emit

Simple signals library for Swift
Swift
6
star
22

udp-logger

UDP logging to logstash for logback and log4j.
Scala
6
star
23

microservice-graph-explorer-test

Runs services that implement the Health Checks API to be used when testing the Microservice Graph Explorer
Go
5
star
24

atlantis-example

A simple terraform project to use along with atlantis bootstrap mode
3
star
25

dropbox-media-library-sample

Media Library Sample App with Auth
JavaScript
1
star
26

atlantis-tests

A set of terraform projects that atlantis e2e tests run on.
HCL
1
star