sunray / coding-standard
The Sunray development coding standard
dev-master
2019-03-07 20:59 UTC
Requires
- php: >=7.3
- slevomat/coding-standard: ^4.0
- squizlabs/php_codesniffer: ^3.2.3
This package is auto-updated.
Last update: 2024-10-08 09:09:14 UTC
README
A coding standard to use for common PHP and JavaScript modules.
The main objectives of this standard are outlined in the Sunray Coding Philosophy which aims to create an efficient development workflow resulting from readable, debuggable, and maintainable code. The general principles are:
- Consistency
- Strict and Predictable Code
- Minimize The Impact of Change
- Optimize for Readability
- Optimize for Code Completion
PHP
The PHP specific coding standards are outlined in a separate document.
Requirements
- PHP 7.1+
- Composer
Installation
- Add
"sunray/coding-standard": "dev-master"
to therequire-dev
block in your application'scomposer.json
as follows:{ "require-dev": { "sunray/coding-standard": "dev-master" } }
or automatically:composer require --dev sunray/coding-standard:dev-master
Usage
- Create a
phpcs.xml
file in the root of your application as follows:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xml> <ruleset name="ProjectName"> <!-- Configure Project Paths --> <!-- PHPCS Settings --> <arg value="p" /> <arg value="s" /> <arg name="basepath" value="." /> <arg name="colors" /> <arg name="cache" /> <arg name="extensions" value="php" /> <arg name="encoding" value="utf-8"/> <arg name="report-width" value="80" /> <!-- Include the Sunray coding standard --> <rule ref="vendor/sunray/coding-standard/ruleset.xml" /> </ruleset>
- From your application root execute the following:
vendor/bin/phpcs