Download the PHP package efureev/php-cs-fixer-1 without Composer

On this page you can find all versions of the php package efureev/php-cs-fixer-1. 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-cs-fixer-1

PHP Coding Standards Fixer

The PHP Coding Standards Fixer (PHP CS Fixer) tool fixes your code to follow standards; whether you want to follow PHP coding standards as defined in the PSR-1, PSR-2, etc., or other community driven ones like the Symfony one. You can also define your (teams) style through configuration.

It can modernize your code (like converting the pow function to the ** operator on PHP 5.6) and (micro) optimize it.

If you are already using a linter to identify coding standards problems in your code, you know that fixing them by hand is tedious, especially on large projects. This tool does not only detect them, but also fixes them for you.

The PHP CS Fixer is maintained on GitHub at https://github.com/FriendsOfPHP/PHP-CS-Fixer bug reports and ideas about new features are welcome there.

You can talk to us at https://gitter.im/PHP-CS-Fixer/Lobby about the project, configuration, possible improvements, ideas and questions, please visit us!

Requirements

PHP needs to be a minimum version of PHP 5.6.0.

Installation

Locally

Download the php-cs-fixer.phar file and store it somewhere on your computer.

Globally (manual)

You can run these commands to easily access latest php-cs-fixer from anywhere on your system:

$ wget https://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -O php-cs-fixer

or with specified version:

$ wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.13.1/php-cs-fixer.phar -O php-cs-fixer

or with curl:

$ curl -L https://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -o php-cs-fixer

then:

$ sudo chmod a+x php-cs-fixer
$ sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer

Then, just run php-cs-fixer.

Globally (Composer)

To install PHP CS Fixer, install Composer and issue the following command:

$ composer global require friendsofphp/php-cs-fixer

Then make sure you have the global Composer binaries directory in your PATH. This directory is platform-dependent, see Composer documentation for details. Example for some Unix systems:

$ export PATH="$PATH:$HOME/.composer/vendor/bin"

Globally (homebrew)

$ brew install php-cs-fixer

Locally (PHIVE)

Install PHIVE and issue the following command:

$ phive install php-cs-fixer # use `--global` for global install

Update

Locally

The self-update command tries to update php-cs-fixer itself:

$ php php-cs-fixer.phar self-update

Globally (manual)

You can update php-cs-fixer through this command:

$ sudo php-cs-fixer self-update

Globally (Composer)

You can update php-cs-fixer through this command:

$ ./composer.phar global update friendsofphp/php-cs-fixer

Globally (homebrew)

You can update php-cs-fixer through this command:

$ brew upgrade php-cs-fixer

Locally (PHIVE)

$ phive update php-cs-fixer

Usage

The fix command tries to fix as much coding standards problems as possible on a given file or files in a given directory and its subdirectories:

$ php php-cs-fixer.phar fix /path/to/dir
$ php php-cs-fixer.phar fix /path/to/file

By default --path-mode is set to override, which means, that if you specify the path to a file or a directory via command arguments, then the paths provided to a Finder in config file will be ignored. You can use --path-mode=intersection to merge paths from the config file and from the argument:

$ php php-cs-fixer.phar fix --path-mode=intersection /path/to/dir

The --format option for the output format. Supported formats are txt (default one), json, xml, checkstyle and junit.

NOTE: the output for the following formats are generated in accordance with XML schemas

The --verbose option will show the applied rules. When using the txt format it will also displays progress notifications.

The --rules option limits the rules to apply on the project:

$ php php-cs-fixer.phar fix /path/to/project --rules=@PSR2

By default the PSR1 and PSR2 rules are used.

The --rules option lets you choose the exact rules to apply (the rule names must be separated by a comma):

$ php php-cs-fixer.phar fix /path/to/dir --rules=line_ending,full_opening_tag,indentation_type

You can also blacklist the rules you don't want by placing a dash in front of the rule name, if this is more convenient, using -name_of_fixer:

$ php php-cs-fixer.phar fix /path/to/dir --rules=-full_opening_tag,-indentation_type

When using combinations of exact and blacklist rules, applying exact rules along with above blacklisted results:

$ php php-cs-fixer.phar fix /path/to/project --rules=@Symfony,-@PSR1,-blank_line_before_statement,strict_comparison

Complete configuration for rules can be supplied using a json formatted string.

$ php php-cs-fixer.phar fix /path/to/project --rules='{"concat_space": {"spacing": "none"}}'

The --dry-run flag will run the fixer without making changes to your files.

The --diff flag can be used to let the fixer output all the changes it makes.

The --diff-format option allows to specify in which format the fixer should output the changes it makes:

The --allow-risky option (pass yes or no) allows you to set whether risky rules may run. Default value is taken from config file. Risky rule is a rule, which could change code behaviour. By default no risky rules are run.

The --stop-on-violation flag stops the execution upon first file that needs to be fixed.

The --show-progress option allows you to choose the way process progress is rendered:

If the option is not provided, it defaults to run-in unless a config file that disables output is used, in which case it defaults to none. This option has no effect if the verbosity of the command is less than verbose.

$ php php-cs-fixer.phar fix --verbose --show-progress=estimating

The command can also read from standard input, in which case it won't automatically fix anything:

$ cat foo.php | php php-cs-fixer.phar fix --diff -

Finally, if you don't need BC kept on CLI level, you might use `PHP_CS_FIXER_FUTURE_MODE` to start using options that would be default in next MAJOR release (unified differ, estimating, full-width progress indicator):

$ PHP_CS_FIXER_FUTURE_MODE=1 php php-cs-fixer.phar fix -v --diff

Choose from the list of available rules:

The --dry-run option displays the files that need to be fixed but without actually modifying them:

$ php php-cs-fixer.phar fix /path/to/code --dry-run

Config file

Instead of using command line options to customize the rule, you can save the project configuration in a .php_cs.dist file in the root directory of your project. The file must return an instance of PhpCsFixer\\ConfigInterface which lets you configure the rules, the files and directories that need to be analyzed. You may also create .php_cs file, which is the local configuration that will be used instead of the project configuration. It is a good practice to add that file into your .gitignore file. With the --config option you can specify the path to the .php_cs file.

The example below will add two rules to the default list of PSR2 set rules:

<?php

$finder = PhpCsFixer\Finder::create()
    ->exclude('somedir')
    ->notPath('src/Symfony/Component/Translation/Tests/fixtures/resources.php')
    ->in(__DIR__)
;

return PhpCsFixer\Config::create()
    ->setRules([
        '@PSR2' => true,
        'strict_param' => true,
        'array_syntax' => ['syntax' => 'short'],
    ])
    ->setFinder($finder)
;

NOTE: exclude will work only for directories, so if you need to exclude file, try notPath.

See Symfony\\Finder online documentation for other `Finder` methods.

You may also use a blacklist for the rules instead of the above shown whitelist approach. The following example shows how to use all Symfony rules but the full_opening_tag rule.

<?php

$finder = PhpCsFixer\Finder::create()
    ->exclude('somedir')
    ->in(__DIR__)
;

return PhpCsFixer\Config::create()
    ->setRules([
        '@Symfony' => true,
        'full_opening_tag' => false,
    ])
    ->setFinder($finder)
;

You may want to use non-linux whitespaces in your project. Then you need to configure them in your config file.

<?php

return PhpCsFixer\Config::create()
    ->setIndent("\t")
    ->setLineEnding("\r\n")
;

By using --using-cache option with yes or no you can set if the caching mechanism should be used.

Caching

The caching mechanism is enabled by default. This will speed up further runs by fixing only files that were modified since the last run. The tool will fix all files if the tool version has changed or the list of rules has changed. Cache is supported only for tool downloaded as phar file or installed via composer.

Cache can be disabled via --using-cache option or config file:

<?php

return PhpCsFixer\Config::create()
    ->setUsingCache(false)
;

Cache file can be specified via --cache-file option or config file:

<?php

return PhpCsFixer\Config::create()
    ->setCacheFile(__DIR__.'/.php_cs.cache')
;

Using PHP CS Fixer on CI

Require friendsofphp/php-cs-fixer as a dev dependency:

$ ./composer.phar require --dev friendsofphp/php-cs-fixer

Then, add the following command to your CI:

$ IFS='
$ '
$ CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "${COMMIT_RANGE}")
$ if ! echo "${CHANGED_FILES}" | grep -qE "^(\\.php_cs(\\.dist)?|composer\\.lock)$"; then EXTRA_ARGS=$(printf -- '--path-mode=intersection\n--\n%s' "${CHANGED_FILES}"); else EXTRA_ARGS=''; fi
$ vendor/bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --stop-on-violation --using-cache=no ${EXTRA_ARGS}

Where $COMMIT_RANGE is your range of commits, eg $TRAVIS_COMMIT_RANGE or HEAD~..HEAD.

Exit codes

Exit code is built using following bit flags:

(applies to exit codes of the `fix` command only)

Helpers

Dedicated plugins exist for:

Contribute

The tool comes with quite a few built-in fixers, but everyone is more than welcome to contribute more of them.

Fixers

A fixer is a class that tries to fix one CS issue (a Fixer class must implement FixerInterface).

Configs

A config knows about the CS rules and the files and directories that must be scanned by the tool when run in the directory of your project. It is useful for projects that follow a well-known directory structures (like for Symfony projects for instance).


All versions of php-cs-fixer-1 with dependencies

PHP Build Version
Package Version
Requires php Version ^5.6 || >=7.0 <=7.3
ext-json Version *
ext-tokenizer Version *
composer/semver Version ^1.4
composer/xdebug-handler Version ^1.2
doctrine/annotations Version ^1.2
php-cs-fixer/diff Version ^1.3
symfony/console Version ^3.4.17 || ^4.1.6
symfony/event-dispatcher Version ^3.0 || ^4.0
symfony/filesystem Version ^3.0 || ^4.0
symfony/finder Version ^3.0 || ^4.0
symfony/options-resolver Version ^3.0 || ^4.0
symfony/polyfill-php70 Version ^1.0
symfony/polyfill-php72 Version ^1.4
symfony/process Version ^3.0 || ^4.0
symfony/stopwatch Version ^3.0 || ^4.0
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 efureev/php-cs-fixer-1 contains the following files

Loading the files please wait ....