Setting up PHP CodeSniffer for a Laravel Application

Published under Laravel.

Here's how you can quickly get started with linting your PHP code using the CodeSniffer library.

First, install the dependency:

composer require "squizlabs/php_codesniffer=*"

Then, create a file at the root of your repo: phpcs.xml

This file tells CodeSniffer which ruleset and rules you want to use. The above will use the PSR2 ruleset, while excluding the CamelCapsMethodName rule (I prefer the it_does_something method name formatting for tests).

Thanks for reading!

Did you find this post useful? Let me know on Twitter! If you found an issue with the content, submit a pull request!

Subscribe to my newsletter to know when I publish more content in the future.

❤️ Likes: 0
📣 Retweets: 0
💬 Replies: 0
🙊 Mentions: 0