Download the PHP package weerd/php-style without Composer
On this page you can find all versions of the php package weerd/php-style. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download weerd/php-style
More information about weerd/php-style
Files in weerd/php-style
Package php-style
Short Description Shareable pre-configured base style rules for the PHP Code Standards Fixer tool.
License MIT
Informations about the package php-style
✨ PHP Styles ✨
This package provides a simple way to apply pre-configured base style rules for the PHP Code Standards Fixer tool, that can be easily shared across projects and packages using PHP 7+.
It can be configured using the default
rules or you can specify a different supported base ruleset, along with any additional rules or overrides you would like to include.
Installation
Usage
Add a .php_cs.dist
in the root directory of your project or pacakge.
Within that file create a new instance of PhpCsFixer\Finder
and configure what files and directories the PHP CS Fixer tool should be looking to fix code style.
Next, call the Weerd\PhpStyle\configure()
function and pass the instance of the finder as the first argument.
Below are some examples along with variations utilizing the $options
array:
Example using default ruleset
The following example returns a configuration with the default rules for PHP styles.
Example using default ruleset and additional rules
The following example returns a configuration with the default rules, along with two additional rules included in the final set of rules for PHP styles.
Example using laravel ruleset
The following example returns a configuration with the laravel rules for PHP styles.
Once you have the .php_cs.dist
file setup, you can run the PHP CS Fixer tool by running:
Or to make things easier, add that command to the composer.json
file as a script:
Now you can run the PHP CS Fixer tool with the following composer command:
Credits
🙌 Thanks to @Spatie and their Laravel Package Training course for introducing me to the PHP Code Standards Fixer tool and how to use it!
🙌 This package is heavily inspired by @timacdonald's great article on how to share PHP CS Fixer rules!
🙌 The complete set of Laravel specific rules are thanks to @laravel-shift and the compiled rules shared in a gist and used on Laravel Shift!