Skip to content

Instantly share code, notes, and snippets.

Created August 20, 2017 16:50
Show Gist options
  • Save paulund/8aacc8e8216c21136c182576fc078ec4 to your computer and use it in GitHub Desktop.
Save paulund/8aacc8e8216c21136c182576fc078ec4 to your computer and use it in GitHub Desktop.
PHP PSR-2 CodeSniffer Config for Laravel
<?xml version="1.0"?>
<ruleset name="Laravel Standards">
The name attribute of the ruleset tag is displayed
when running PHP_CodeSniffer with the -v command line
argument. The description tag below is not displayed anywhere
except in this file, so it can contain information for
developers who may change this file in the future.
<description>The Laravel Coding Standards</description>
If no files or directories are specified on the command line
your custom standard can specify what files should be checked
Note that specifying any file or directory path
on the command line will ignore all file tags.
You can hard-code ignore patterns directly into your
custom standard so you don't have to specify the
patterns on the command line.
You can hard-code command line values into your custom standard.
Note that this does not work for the command line values:
-v[v][v], -l, -d, -sniffs and -standard
The following tags are equivalent to the command line arguments:
<arg name="report" value="summary"/>
<arg name="colors"/>
<arg value="p"/>
You can hard-code custom php.ini settings into your custom standard.
The following tag sets the memory limit to 64M.
<ini name="memory_limit" value="128M"/>
Include all sniffs in the PEAR standard. Note that the
path to the standard does not have to be specified as the
PEAR standard exists inside the PHP_CodeSniffer install
<rule ref="PSR2"/>
Copy link

Hi Paul,

I'm using this GIST as a starting point. But I've found that defining the files in the <file> list isn't acting recursively?

Is there a way to do that, or do I HAVE to list each folder separately. For example, using your config, my phpcs isn't crawling through app/Http/Controllers.

Copy link

kamihouse commented Sep 18, 2018

@fredbradley did you get around this?

Don't use l on <arg value="p"/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment