PHPackages                             socialengine/sniffer-rules - 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. [CLI &amp; Console](/categories/cli)
4. /
5. socialengine/sniffer-rules

ActiveLibrary[CLI &amp; Console](/categories/cli)

socialengine/sniffer-rules
==========================

A Lumen 5 and Laravel 5 SquizLabs Code Sniffer 2.0 artisan command. Detect violations of a defined coding standard. It helps your code remains clean and consistent.

2.3.0(8y ago)1248.2k41MITPHPPHP &gt;=5.4.0

Since Sep 20Pushed 8y ago15 watchersCompare

[ Source](https://github.com/SocialEngine/sniffer-rules)[ Packagist](https://packagist.org/packages/socialengine/sniffer-rules)[ Docs](https://github.com/socialengine/sniffer-rules)[ RSS](/packages/socialengine-sniffer-rules/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (14)Used By (1)

phpcs 2.0+ Laravel 5, Lumen 5 Command
=====================================

[](#phpcs-20-laravel-5-lumen-5-command)

[![Build Status](https://camo.githubusercontent.com/84682a28277c1fbc3666445ab0e5480c36880be481e4bc102a49d2bf25644871/68747470733a2f2f7472617669732d63692e6f72672f536f6369616c456e67696e652f736e69666665722d72756c65732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/SocialEngine/sniffer-rules)[![Latest Stable Version](https://camo.githubusercontent.com/2d8d5a326bffc867ffd91ca170dfdd1f15ac807ed2c66bcf7dc22eb873e83e8b/68747470733a2f2f706f7365722e707567782e6f72672f536f6369616c456e67696e652f736e69666665722d72756c65732f76657273696f6e2e706e67)](https://packagist.org/packages/SocialEngine/sniffer-rules)[![License](https://camo.githubusercontent.com/0e7fb0d9041a25af1d43ee0c11f67e4ff87c42f4bd09077d1210da46e27851f4/68747470733a2f2f706f7365722e707567782e6f72672f536f6369616c456e67696e652f736e69666665722d72756c65732f6c6963656e73652e737667)](https://packagist.org/packages/SocialEngine/sniffer-rules)

This is a [Laravel](http://laravel.com/) 5 package that hooks up [SquizLabs CodeSniffer 2](https://github.com/squizlabs/PHP_CodeSniffer)into Laravel-based apps. It can also be used manually, so read on.

Detect violations of a defined coding standard. It helps your code remain clean and consistent. Available options are: **PSR2**, **PSR1**, **Zend**, **PEAR**, **Squiz**, **PHPCS** and **SocialEngine**.

### Setup

[](#setup)

Require this package in composer:

```
$ composer require socialengine/sniffer-rules

```

#### Laravel 5

[](#laravel-5)

In your `config/app.php` add `'SocialEngine\SnifferRules\ServiceProvider'`to `$providers` array:

```
'providers' => [
    'Illuminate\Foundation\Providers\ArtisanServiceProvider',
    'Illuminate\Auth\AuthServiceProvider',

    'SocialEngine\SnifferRules\ServiceProvider',

],
```

#### Laravel 5: Publish the configuration file

[](#laravel-5-publish-the-configuration-file)

```
$ php artisan vendor:publish
```

#### Manual

[](#manual)

Install our *Standard* by configuring **PHP\_CodeSniffer** to look for it.

```
$ php ./vendor/bin/phpcs --config-set installed_paths ./vendor/socialengine/src/Socialengine/SnifferRules/Standard/
```

### Usage

[](#usage)

#### Laravel

[](#laravel)

```
$ php artisan sniff
```

To run the sniffer in a CI environment, the `-n` option should be set to remove interaction:

```
$ php artisan sniff -n

```

#### Manual

[](#manual-1)

```
$ php ./vendor/bin/phpcs --standard=SocialEngine path/to/code
```

It's encouraged to add a [`Makefile`](Makefile) to your project that makes it trivial for other developers. Use `Makefile` in this directory and adjust as needed to fit your project requirements.

### Travis

[](#travis)

In combination with the [`Makefile`](Makefile), Travis has issues finding the standard, we had to add a `before_script` to make it work. See [Unum](https://github.com/SocialEngine/Unum) repo for example.

```
before_script: php ./vendor/bin/phpcs --config-set installed_paths "`pwd`/vendor/socialengine/sniffer-rules/src/SocialEngine/SnifferRules/Standard/"
```

SocialEngine Coding Standards
-----------------------------

[](#socialengine-coding-standards)

### Coding standards

[](#coding-standards)

- [PSR 2 Coding Style Guide](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
- [PSR 1 Coding Standards](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md)
- [PSR 0 Coding Standards](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md)

#### Addendum and Clarifications

[](#addendum-and-clarifications)

- `namespace` should be on the same line as opening php tag. e.g.: `
