https://github.com/socialengine/sniffer-rules
SocialEngine specific laravel-bound code sniffer package
https://github.com/socialengine/sniffer-rules
Last synced: about 1 year ago
JSON representation
SocialEngine specific laravel-bound code sniffer package
- Host: GitHub
- URL: https://github.com/socialengine/sniffer-rules
- Owner: SocialEngine
- License: mit
- Created: 2014-09-15T05:09:44.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2017-09-29T21:01:30.000Z (almost 9 years ago)
- Last Synced: 2025-03-25T17:23:34.210Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 57.6 KB
- Stars: 12
- Watchers: 15
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# phpcs 2.0+ Laravel 5, Lumen 5 Command
[](https://travis-ci.org/SocialEngine/sniffer-rules)
[](https://packagist.org/packages/SocialEngine/sniffer-rules)
[](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
Require this package in composer:
```
$ composer require socialengine/sniffer-rules
```
#### Laravel 5
In your `config/app.php` add `'SocialEngine\SnifferRules\ServiceProvider'`
to `$providers` array:
```php
'providers' => [
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
'SocialEngine\SnifferRules\ServiceProvider',
],
```
#### Laravel 5: Publish the configuration file
```bash
$ php artisan vendor:publish
```
#### Manual
Install our _Standard_ by configuring **PHP_CodeSniffer** to look for it.
```bash
$ php ./vendor/bin/phpcs --config-set installed_paths ./vendor/socialengine/src/Socialengine/SnifferRules/Standard/
```
### Usage
#### Laravel
```bash
$ 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
```bash
$ 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
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.
```yml
before_script: php ./vendor/bin/phpcs --config-set installed_paths "`pwd`/vendor/socialengine/sniffer-rules/src/SocialEngine/SnifferRules/Standard/"
```
## SocialEngine 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
* `namespace` should be on the same line as opening php tag. e.g.: `