lemberg / laravel-code-style-command
Check code style.
Installs: 5 205
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 12
Forks: 0
Open Issues: 0
Requires
- php: >=7.0.0
- laravel/framework: 5.5 - 5.8
- squizlabs/php_codesniffer: 3.2.*
Requires (Dev)
This package is auto-updated.
Last update: 2024-10-15 18:41:31 UTC
README
This package adds simple artisan
command over PHP_CodeSniffer script.
Validate PSR2 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 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 for more information.