Download the PHP package 26b/php-pre-commit without Composer

On this page you can find all versions of the php package 26b/php-pre-commit. 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 php-pre-commit

php-pre-commit

Pre-commit git hook for enforcing php standards.

Currently uses PHP_CodeSniffer (PHPCS) and corrects .php staged files according to a phpcs config file (usually a phpcs.xml).

Install via the composer command:

In order for the hooks to be moved into the .git/hooks folder add the following to the project's composer.json:

With composer install or composer update the pre-commit hook will be moved into .git/hooks.

If you want to skip the pre-commit execution, you can add the argument --no-verify to git commit.

[!IMPORTANT] This package does not require PHPCS because it is up to you whether you want to use a local or global phpcs. Local phpcs takes precedence when the pre-commit runs. You can require them in the following way:

Use Cases

Local PHPCS

If you intend to use different sets of standards in different repositories we advise you to install php_codesniffer locally, this will make sure that there will be no conflicts when configuring phpcs --config-set ... later on. In case you choose the local approach make sure to correct the PHPCS path on the examples below.

Usually it would be something like changing all phpcs references to ./vendor/bin/phpcs (or any other local path).

WordPress

Setup WordPress Standards (Manual)

First we need to clone the WordPress standards repository. It should be placed in a directory that phpcs can access. We placed ours in the home directory wpcs directory in root. Clone the repository into the wpcs folder via:

Secondly, we need to tell phpcs where these standards are.

Finally, in order to check that phpcs recognises and uses the standards, we can check it like this:

The output should resemble this, with the WordPress standards. If they are missing, phpcs might not be recognising the path. Check its paths via:

Alternative (Automatic)

As an alternative you can use PHP_CodeSniffer Standards Composer Installer Plugin which helps to automatically link the wanted standards to phpcs. Be aware that it requires phpcs locally and so our pre-commit hook will use that phpcs. We can then require this package and WPCS in the following manner:

Or add them to the composer.json:

And add scripts, to configure phpcs correctly upon composer install, like this:

Laravel

Automatic Setup

Here, you can also use PHP_CodeSniffer Standards Composer Installer Plugin to automatically link the Laravel standards to phpcs. Again, make sure phpcs is installed locally and so our pre-commit. We just need to require emielmolenaar/phpcs-laravel package and we are done:

Finally, add the same scripts to configure phpcs correctly upon composer install:

Manual Setup

A Laravel's coding standard repository that is being updated consistently is emielmolenaar/phpcs-laravel. We will now proceed to the configuration (very similar to the WordPress configuration). First clone emielmolenaar/phpcs-laravel repository:

Again, tell to phpcs where the standards are.

Once more, make sure phpcs recognises and uses the installed standards:

The --config-show will give the following output:

Troubleshooting


All versions of php-pre-commit with dependencies

PHP Build Version
Package Version
No informations.
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 26b/php-pre-commit contains the following files

Loading the files please wait ....