kevyworks
A PHP-CS-Fixer bridge for use via Artisan CLI on Laravel 5.5+
This package allows to use PHP-CS-Fixer right into Laravel 5.5+ applications to format PHP code following PSR-1 and PSR-2 coding standards.
Important:
Default PHP-CS-Fixer config was updated in v2 to remove dependency to@Symfony
ruleset and be more compliant with Laravel coding style.
If needed, you'll find v1 config here.
Forked from bgaze/laravel-php-cs-fixer
This package is an adapted copy of https://github.com/JackieDo/Artisan-PHP-CS-Fixer.
Credits and many thanks to JackieDo :-)
Install this package using Composer.
$ composer require bgaze/laravel-php-cs-fixer
To customize the configuration, publish it :
$ php artisan vendor:publish --tag=bgaze-php-cs-fixer-config
Note :
Configuration isn't a standard Laravel config files as it returns an instance of\PhpCsFixer\Config
.
It will be published into a.php-cs
file at the Laravel installation root.
Please see PHP-CS-Fixer documentation for more details.
Fix your code with PHP Coding Standards.
Usage:
$ php artisan php-cs-fixer:fix [options] [path/to/dir/or/file]
Syntax:
Usage:
$ php-cs-fixer:fix [options] path1 [path2 path3 ...]
Arguments:
path Path to directory or file (multiple values allowed).
Options:
--allow-risky Allow risky fixers.
--dry-run Only shows which files would have been modified, leaving your files unchanged.
--stop-on-violation Stop execution on first violation.
--diff Also produce diff for each file.
--using-cache Enable cache usage.
--path-mode[=PATH-MODE] Specify path mode (override|intersection). [default: "override"]
--config[=CONFIG] The path to a .php-cs-fixer file.
--rules[=RULES] The rules to apply for fixer (comma separated).
--cache-file[=CACHE-FILE] The path to the cache file.
--format[=FORMAT] To output results in other formats.
--show-progress[=SHOW-PROGRESS] Type of progress indicator (none|run-in|estimating). [default: "none"]
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Default config files .php_cs.dist
and .php_cs
Examples:
// Only shows which all files in your project would have been modified, leaving your files unchanged.
$ php artisan php-cs-fixer:fix --dry-run
// Really fixes all files in your project.
$ php artisan php-cs-fixer:fix
// Only fixes all files in the `app` directory.
$ php artisan php-cs-fixer:fix app
// Only fixes all files in the `app` directory with specific configuration file.
$ php artisan php-cs-fixer:fix --config="path/to/config/file" app
The php_cs_fixer() helper wraps php-cs-fixer:fix command and allows to fix files right from the code.
It returns the exit code of the command.
Usage :
// $path : a path or an array of paths.
// $options : an array of options.
php_cs_fixer($path, $options);
Examples :
// Quick.
php_cs_fixer('path/to/a/file/or/dir');
// Advanced.
php_cs_fixer(['path/to/file/or/dir/1', 'path/to/file/or/dir/2'], [
'--allow-risky' => true,
'--dry-run' => true,
'--config' => 'path/to/a/config/file'
]);
Usage:
$ php-cs-fixer:describe name
Arguments:
name Name of rule / set.
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Displays PHP-CS-Fixer version installed.
Usage:
$ php artisan php-cs-fixer:version