PHPackages                             silverorange/coding-standard - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. silverorange/coding-standard

ActivePhpcodesniffer-standard[PSR &amp; Standards](/categories/psr-standards)

silverorange/coding-standard
============================

silverorange PHP coding standards.

1.1.1(3y ago)14.3k72MITPHP

Since Jun 27Pushed 3mo ago17 watchersCompare

[ Source](https://github.com/silverorange/coding-standard)[ Packagist](https://packagist.org/packages/silverorange/coding-standard)[ Docs](https://github.com/silverorange/coding_standard)[ RSS](/packages/silverorange-coding-standard/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (12)Used By (2)

silverorange Coding Standards
=============================

[](#silverorange-coding-standards)

[![Build Status](https://camo.githubusercontent.com/c3df80ffae6426b89603e6083931ea10e31c669c2345941f844d7e1c53c5229f/68747470733a2f2f7472617669732d63692e6f72672f73696c7665726f72616e67652f636f64696e672d7374616e646172642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/silverorange/coding-standard)

Coding standards for silverorange PHP projects. These are standards to be used with the [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer/wiki) tool.

Per-Project Usage
-----------------

[](#per-project-usage)

per-project configuration is preferred over global configuration but does require support to be added to the project. To use these rules for a project:

### 1. install as a require-dev dependency using composer

[](#1-install-as-a-require-dev-dependency-using-composer)

```
$ composer require --dev silverorange/coding-standard squizlabs/php_codesniffer
```

### 2. add a `post-install-cmd` and `post-update-cmd` to register the coding standard with phpcs

[](#2-add-a-post-install-cmd-and-post-update-cmd-to-register-the-coding-standard-with-phpcs)

Post install and post update are both required because `composer install`without a lock file will not execute the `post-install-cmd` script.

```
{
  "scripts": {
    "post-install-cmd": "./vendor/bin/phpcs --config-set installed_paths vendor/silverorange/coding-standard/src",
    "post-update-cmd": "./vendor/bin/phpcs --config-set installed_paths vendor/silverorange/coding-standard/src"
  }
}
```

### 3. create a phpcs.xml

[](#3-create-a-phpcsxml)

```

  A custom coding standard.

```

### 4. create a composer script to lint the project

[](#4-create-a-composer-script-to-lint-the-project)

```
{
  "scripts": {
    "lint": "./vendor/bin/phpcs"
  }
}
```

### 5. add a Jenkins pipeline stage to automatically lint files

[](#5-add-a-jenkins-pipeline-stage-to-automatically-lint-files)

The code lint pipeline stage should be added before other pipeline stages so they do not run if the code lint fails. See the [Jenkins Pipeline Manual](https://jenkins.io/doc/book/pipeline/) for help with adding a stage to an existing pipeline, or for help creating a new pipeline.

For new packages:

```
stage('Lint Modified Files') {
  when {
    not {
      branch 'master'
    }
  }
  steps {
    sh '''
      master_sha=$(git rev-parse origin/master)
      newest_sha=$(git rev-parse HEAD)
      files=$(git diff --diff-filter=ACRM --name-only $master_sha...$newest_sha)

      if [ -n "$files" ]; then
        ./vendor/bin/phpcs \
          --standard=Silverorange \
          --tab-width=4 \
          --encoding=utf-8 \
          --warning-severity=0 \
          --extensions=php \
          $files
      fi
    '''
  }
}
```

For legacy packages:

```
stage('Lint Modified Files') {
  when {
    not {
      branch 'master'
    }
  }
  steps {
    sh '''
      master_sha=$(git rev-parse origin/master)
      newest_sha=$(git rev-parse HEAD)
      files=$(git diff --diff-filter=ACRM --name-only $master_sha...$newest_sha)

      if [ -n "$files" ]; then
        ./vendor/bin/phpcs \
          --standard=SilverorangeTransitional \
          --tab-width=4 \
          --encoding=utf-8 \
          --warning-severity=0 \
          --extensions=php \
          $files
      fi
    '''
  }
}
```

Global Usage
------------

[](#global-usage)

The `SilverorangeLegacy` standard can be set to be used by default if no per-project configuration is available.

### 1. Install standard globally

[](#1-install-standard-globally)

```
$ composer global require silverorange/coding-standard:dev-master
```

### 2. Register the standard with PHP Code Sniffer

[](#2-register-the-standard-with-php-code-sniffer)

You can use commas to delineate multiple paths.

```
$ phpcs --config-set installed_paths ~/.composer/vendor/silverorange/coding-standard/src
```

### 3. Set the global phpcs standard

[](#3-set-the-global-phpcs-standard)

```
$ phpcs --config-set default_standard SilverorangeLegacy
```

Now calling `phpcs` with no additional arguments will use the `SilverorangeLegacy` standard.

Standards
---------

[](#standards)

Several standards are provided:

### SilverorangeLegacy

[](#silverorangelegacy)

Intended for linting the entire project for a legacy package. This omits some rules we'd like to use for new code written for legacy packages in order to run without error. It is not recommended to use this standard for new projects.

[Documentation](doc/legacy/README.md) exists for the legacy standard.

### SilverorangeTransitional

[](#silverorangetransitional)

Intended for use as a post-commit hook or CI test. This ensures all new code added to legacy packages follows best practices within the legacy guidelines. This includes rules that will not pass for the entire project, but should pass for all modified files in a new pull request.

### SilverorangeTransitionalPrettier

[](#silverorangetransitionalprettier)

Based on [PSR-2](http://www.php-fig.org/psr/psr-2/) standard but updated to support [Prettier code auto-formatting](https://github.com/prettier/plugin-php). The PSR-4 autoloading rules of PSR-2 are relaxed to allow our legacy code to comply with the ruleset. This standard should be used for all legacy silverorange PHP packages.

### Silverorange

[](#silverorange)

Based on [PSR-2](http://www.php-fig.org/psr/psr-2/). PSR-2 builds on, and includes all rules from [PSR-1](http://www.php-fig.org/psr/psr-1/), The `Silverorange` standard extends PSR-2 to add forbidden functions.

For autoloading classes, projects must follow [PSR-4](http://www.php-fig.org/psr/psr-4/). This allows efficient auto-loading and promotes organizing code using namespaces.

### SilverorangePrettier

[](#silverorangeprettier)

Based on `Silverorange` standard but updated to support [Prettier code auto-formatting](https://github.com/prettier/plugin-php). In addition to PSR-2 rules, additional checks are included to promote code quality and consistency. This standard should be used for all new silverorange PHP packages.

### SilverorangePEAR

[](#silverorangepear)

Based on `PEAR` standard but updated to not require method and class documentation. This should *not* be used for new packages.

Sublime Setup
-------------

[](#sublime-setup)

If you are using Sublime Text:

1. Set up Sublime Linter with PHPCS as described [here](https://github.com/SublimeLinter/SublimeLinter-phpcs).
2. In the Sublime Linter settings, make sure you have the following settings (do not remove the other settings): ```
    {
      "user": {
        "linters": {
          "phpcs": {
            "@disable": false,
            "args": []
          }
        }
      }
    }
    ```
3. Create a Sublime project in the project root.
4. Add the following to the Sublime project settings: ```
    {
      "SublimeLinter": {
        "linters": {
          "phpcs": {
            "phpcs_executable_path": "{project}/vendor/bin/phpcs"
          }
        }
      }
    }
    ```

This will allow you to use different rulesets with different projects.

Atom Setup
----------

[](#atom-setup)

If you are using Atom:

1. Set up linter-phpcs as described [here](https://atom.io/packages/linter-phpcs).
2. Open the package settings for linter-phpcs and set `Coding Standard Or Config File` to `SilverorangeLegacy` or whichever current coding standard you are using. Also set the `Tab Width` field to `4`.

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance54

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community26

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 63.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~204 days

Recently: every ~503 days

Total

11

Last Release

1249d ago

Major Versions

0.7.0 → 1.0.02018-02-27

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/166810?v=4)[Colin Viebrock](/maintainers/cviebrock)[@cviebrock](https://github.com/cviebrock)

![](https://avatars.githubusercontent.com/u/120511?v=4)[Michael Gauthier](/maintainers/gauthierm)[@gauthierm](https://github.com/gauthierm)

---

Top Contributors

[![gauthierm](https://avatars.githubusercontent.com/u/120511?v=4)](https://github.com/gauthierm "gauthierm (74 commits)")[![Qcode](https://avatars.githubusercontent.com/u/1542145?v=4)](https://github.com/Qcode "Qcode (23 commits)")[![m-mitchell](https://avatars.githubusercontent.com/u/169674?v=4)](https://github.com/m-mitchell "m-mitchell (9 commits)")[![charleswaddell](https://avatars.githubusercontent.com/u/1316827?v=4)](https://github.com/charleswaddell "charleswaddell (5 commits)")[![pparke](https://avatars.githubusercontent.com/u/5822990?v=4)](https://github.com/pparke "pparke (2 commits)")[![GervaisdeM](https://avatars.githubusercontent.com/u/963514?v=4)](https://github.com/GervaisdeM "GervaisdeM (2 commits)")[![rodrigoprimo](https://avatars.githubusercontent.com/u/77215?v=4)](https://github.com/rodrigoprimo "rodrigoprimo (1 commits)")

---

Tags

phpcssilverorange

### Embed Badge

![Health badge](/badges/silverorange-coding-standard/health.svg)

```
[![Health](https://phpackages.com/badges/silverorange-coding-standard/health.svg)](https://phpackages.com/packages/silverorange-coding-standard)
```

###  Alternatives

[phpcompatibility/php-compatibility

A set of sniffs for PHP\_CodeSniffer that checks for PHP cross-version compatibility.

2.3k81.1M1.6k](/packages/phpcompatibility-php-compatibility)[slevomat/coding-standard

Slevomat Coding Standard for PHP\_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.

1.5k134.0M2.2k](/packages/slevomat-coding-standard)[automattic/vipwpcs

PHP\_CodeSniffer rules (sniffs) to enforce WordPress VIP minimum coding conventions

25811.4M196](/packages/automattic-vipwpcs)[wptrt/wpthemereview

PHP\_CodeSniffer rules (sniffs) to verify theme compliance with the rules for theme hosting on wordpress.org

216792.6k30](/packages/wptrt-wpthemereview)[yoast/yoastcs

PHP\_CodeSniffer rules for Yoast projects

221.2M34](/packages/yoast-yoastcs)[joomla/coding-standards

Joomla Coding Standards

132241.0k17](/packages/joomla-coding-standards)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
