https://github.com/lemberg/laravel-code-style-command
https://github.com/lemberg/laravel-code-style-command
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/lemberg/laravel-code-style-command
- Owner: lemberg
- License: mit
- Created: 2018-02-05T10:25:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-14T11:07:24.000Z (over 7 years ago)
- Last Synced: 2025-09-21T19:55:51.782Z (9 months ago)
- Language: PHP
- Size: 21.5 KB
- Stars: 2
- Watchers: 11
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Code Style Command
This package adds simple `artisan` command over [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) script.
Validate [PSR2](https://www.php-fig.org/psr/psr-2/) coding standard in you application.
## Requirements
* PHP >= `7.0`
* Laravel = `5.5.*|5.8.*`
## Getting Started
Add the package in your `composer.json`
```
$ composer require --dev lemberg/laravel-code-style-command
```
So that's all :)
Check you code style in `app/` directory.
```
$ php artisan code-style
```
Example output:
```
FILE: .../bkhrupa/work/lemberg/laravel-code-style-command/app/User.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
8 | ERROR | [x] Opening brace of a class must be on the line after
| | the definition
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
Time: 116ms; Memory: 6Mb
Finished
```
## Advance usage
```
$ php artisan code-style --help
```
### Config file
Publish `code-style.php` config file.
```
$ php artisan vendor:publish --provider="Lemberg\LaravelCsc\LaravelCscServiceProvider"
```
### Git pre-commit hook
Use git [pre-commit](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) hook
Add next code to pre commit hooks file **.git/hooks/pre-commit**.
```
#!/bin/bash
`php ./artisan code-style --print-command`
```
`pre-commit` hook must be executable
```
$ chmod +x .git/hooks/pre-commit
```
## License
Please see [License File](LICENSE.md) for more information.