picklewagon / picklewagon-coding-standards
Enforce PHP coding standards in a PHP project.
Installs: 1 922
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 1
Type:phpcodesniffer-standard
Requires
- php: ~7.0|~8.0
This package is auto-updated.
Last update: 2024-11-15 13:01:35 UTC
README
Include this package in your project to enforce the coding standard used for Picklewagon projects.
Install
Add to composer.json. Since it is a private package, you have to add some dependencies as well.
"require-dev": {
...
"picklewagon/picklewagon-coding-standards": "1.0.0"
},
"repositories": [
{
"type": "vcs",
"url": "git@bitbucket.org:picklewagon/picklewgon-coding-standards.git"
}
],
Run from the command line:
$ composer require squizlabs/php_codesniffer $ composer require wimg/php-compatibility $ composer update picklewagon/picklewagon-coding-standards $ ./vendor/bin/phpcs --config-set installed_paths vendor/picklewagon/php-coding-standards-pkg/,vendor/wimg/php-compatibility/
Verify package installation by running the following command:
$ ./vendor/bin/phpcs -i
You should see the Picklewagon coding standard has now been installed.
Usage
Create a file that your specific repository will use for it's coding standard.
Details can be found at the PHP_CodeSniffer wiki.
Basically, you want to create a phpcs.xml file in the project root.
Here is an example of what will be in this file:
<?xml version="1.0"?> <ruleset name="PrinterInstaller"> <description>The coding standard for the user microservice.</description> <!-- Include these folders --> <file>app</file> <file>bootstrap</file> <file>config</file> <file>database</file> <file>resources</file> <file>routes</file> <file>tests</file> <!-- Don't validate these files --> <exclude-pattern>*.blade.php</exclude-pattern> <exclude-pattern>bootstrap/autoload.php</exclude-pattern> <exclude-pattern>bootstrap/cache/services.php</exclude-pattern> <!-- Configuration --> <!-- Check for cross-version support for PHP 7.1 and higher. --> <config name="testVersion" value="7.1-" /> <!-- Arguments --> <arg value="sp" /> <arg name="extensions" value="php" /> <arg name="report-json" value="build/reports/php/phpcs-code.json" /> <!-- Include the Picklewagon coding standard. --> <rule ref="Picklewagon" /> </ruleset>
You'll need to customize it to the repo where you are installing it.
Run the command:
$ ./vendor/bin/phpcs