spaze/phpcs-phar

PHP_CodeSniffer phar releases

3.9.2 2024-04-23 22:21 UTC

This package is auto-updated.

Last update: 2024-04-23 22:21:40 UTC


README

Create a phar release

This repo contains phar releases of PHPCSStandards/PHP_CodeSniffer.

The files are downloaded from the PHP_CodeSniffer release pages, and if changed, they're commited and a release is created with the same version number as the upstream release.

The whole thing is powered by a GitHub Actions workflow.

I have created this for my personal usage to overcome the performance issues of the 9P filesystem as used by WSL2. The PHPCSStandards organization is also planning to create a Composer phar release so this repository will cease to exist one day, either when the official Composer phar is released, or when the 9P performace is sufficient, or when I retire. Consider yourself warned.

Installation

Install with Composer:

composer require --dev spaze/phpcs-phar

Installing coding standards

The phar releases in this repository do not work with the PHP_CodeSniffer Standards Composer Installer Plugin (the dealerdirect/phpcodesniffer-composer-installer package). Be warned that this package even replaces the installer plugin in its composer.json.

There are several reasons for that:

  1. The installer plugin looks for a different installed package, squizlabs/php_codesniffer to add more standards to
  2. The plugin creates a configuration file with a relative path to the standard being installed, so the code sniffer then expects the standard to be present inside the phar file, which is not the case

However, there are multiple ways to install the standard manually. Let's say you want to add slevomat/coding-standard, you can:

Modify the config file

  1. In your project, run
    vendor/bin/phpcs --config-set installed_paths ../../slevomat/coding-standard
    
  2. Locate the CodeSniffer.conf file in your vendor/spaze/phpcs-phar directory
  3. Edit the path to the installed standard and make it an absolute path, for example change
    'installed_paths' => '../../slevomat/coding-standard'
    to
    'installed_paths' => __DIR__ . '/../../slevomat/coding-standard'

Install the standard using an absolute path

In your project, run

vendor/bin/phpcs --config-set installed_paths $(realpath vendor/slevomat/coding-standard)

or use any absolute path for the installed_paths value.