laravel-phpcs
laravel-phpcs copied to clipboard
PHP Codesniffer ruleset to follow Laravel's definition of PSR-12 coding style
PHP CodeSniffer rules for Laravel coding style (PSR-2 variant)
Authored by fossbarrow IO
php codesniffer ruleset for laravel projects.
Requirements
- https://github.com/squizlabs/PHP_CodeSniffer
Table of contents
-
How to install
- Enabling the rules
- Sniffing code
- Sniffing code in PHPStorm
- License
- Contributing
- Credits
Installation
Install the ruleset by
- Copy the
phpcs.xml
file into your project root with phpcs installed.
Usage
Enabling the rules
Only neccesary if you installed as a package using composer!
Add it to your project phpcs.xml
or phpcs.xml.dist
ruleset:
<?xml version="1.0"?>
<ruleset>
<arg name="basepath" value="."/>
<file>./app</file>
<file>./config</file>
<file>./resources</file>
<file>./routes</file>
<file>./tests</file>
<rule ref="./vendor/fossbarrow/laravel-phpcs/phpcs.xml"/>
</ruleset>
Sniffing code
Use php CodeSniffer commands, pointed towards your xml file, to sniff the code using the new ruleset.
vendor/bin/phpcs vendor/bin/phpcbf
Sniffing code in PHPStorm
See PHP Code Sniffer in PhpStorm on how to set up CodeSniffer in PHPStorm.
Contributing
All changes that makes the sniffer more accurate towards Laravel's coding standard is always highly appreciated and welcome.
Please see CONTRIBUTING for more details.
Credits
- PatricNox
- All Contributors
License
The MIT License (MIT). Please see License File for more information.