https://github.com/spiral/code-style
Code-Style sniffer and fixer rules and CLI command
https://github.com/spiral/code-style
code-style cs-fixer per-2 php psr-12 spiral
Last synced: about 1 month ago
JSON representation
Code-Style sniffer and fixer rules and CLI command
- Host: GitHub
- URL: https://github.com/spiral/code-style
- Owner: spiral
- License: mit
- Created: 2019-10-09T07:41:50.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-10-06T17:25:25.000Z (6 months ago)
- Last Synced: 2025-10-06T19:09:34.891Z (6 months ago)
- Topics: code-style, cs-fixer, per-2, php, psr-12, spiral
- Language: PHP
- Homepage:
- Size: 70.3 KB
- Stars: 7
- Watchers: 8
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Code style presets for Spiral components
This repository contains ruleset for [PHP CS Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) based on PER-2.
## Installation and configuration
Install the package via composer:
```
composer require --dev spiral/code-style
```
[](https://packagist.org/packages/spiral/code-style)
[](https://packagist.org/packages/spiral/code-style)
[](LICENSE.md)
[](https://packagist.org/packages/spiral/code-style)
Create a configuration file `.php-cs-fixer.dist.php` in the root of your project:
```php
include(__DIR__ . '/src')
->include(__FILE__)
->build();
```
Feel free to adjust the paths to include/exclude files and directories.
## Usage
To more convenient usage, you can add the following commands to the `scripts` section of the `composer.json` file:
```json
{
"scripts": {
"cs:diff": "php-cs-fixer fix --dry-run -v --diff",
"cs:fix": "php-cs-fixer fix -v"
}
}
```
Now you can run the following commands:
```bash
composer cs:diff
composer cs:fix
```
## CI integration
If you want to integrate code style check into CI, add the following step to your GitHub Actions configuration file:
```yaml
on:
push:
branches:
- '*'
name: Check Code Style
jobs:
cs-check:
uses: spiral/gh-actions/.github/workflows/cs.yml@master
```
If you want GitHub Actions to automatically fix the found errors, add the following step:
```yaml
on:
push:
branches:
- '*'
name: Fix Code Style
jobs:
cs-fix:
permissions:
contents: write
uses: spiral/gh-actions/.github/workflows/cs-fix.yml@master
```