Skip to content

Commit 637ed79

Browse files
authored
Merge pull request #268 from wayofdev/docs/updates
docs: updating readme
2 parents de8364c + c0add68 commit 637ed79

File tree

3 files changed

+92
-70
lines changed

3 files changed

+92
-70
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ repos:
99
- id: check-added-large-files
1010
args: ['--maxkb=600']
1111

12-
- repo: https://github.com/commitizen-tools/commitizen
13-
rev: v3.26.0
14-
hooks:
15-
- id: commitizen
16-
stages:
17-
- commit-msg
18-
1912
- repo: local
2013
hooks:
2114
- id: php-cs-fixer

README.md

Lines changed: 81 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727

2828
Wrapper with pre-defined rules around the [PHP-CS-Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) package — A tool to automatically fix PHP Coding Standards issues.
2929

30-
If you **like/use** this package, please consider **starring** it. Thanks!
30+
This repository aims to provide a standardized way to apply coding standards across multiple projects, ensuring consistency and adherence to best practices.
31+
32+
By using predefined rulesets, it simplifies the setup process and allows teams to quickly integrate PHP-CS-Fixer into their development workflow.
33+
34+
<br>
35+
36+
If you **like/use** this package, please consider ⭐️ **starring** it. Thanks!
3137

3238
<br>
3339

@@ -38,100 +44,110 @@ If you **like/use** this package, please consider **starring** it. Thanks!
3844
Require as dependency:
3945

4046
```bash
41-
composer req wayofdev/cs-fixer-config
47+
composer req --dev wayofdev/cs-fixer-config
4248
```
4349

4450
<br>
4551

4652
## 🛠 Configuration
4753

48-
1. Create PHP file and name it `.php-cs-fixer.dist.php` and place it inside root directory of project. It will be recognized by PHP CS Fixer automatically.
54+
### → Setup
4955

50-
2. Example contents of `.php-cs-fixer.dist.php` file:
56+
- Create PHP file and name it `.php-cs-fixer.dist.php` and place it inside root directory of project. It will be recognized by PHP CS Fixer automatically.
57+
58+
- Example contents of `.php-cs-fixer.dist.php` file:
5159

5260
```php
53-
<?php
61+
<?php
62+
63+
declare(strict_types=1);
64+
65+
use WayOfDev\PhpCsFixer\Config\ConfigBuilder;
66+
use WayOfDev\PhpCsFixer\Config\RuleSets\DefaultSet;
67+
68+
require_once 'vendor/autoload.php';
69+
70+
$config = ConfigBuilder::createFromRuleSet(new DefaultSet())
71+
->inDir(__DIR__ . '/src')
72+
->inDir(__DIR__ . '/tests')
73+
->addFiles([__FILE__])
74+
->getConfig()
75+
;
76+
77+
$config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/php-cs-fixer.cache');
78+
79+
return $config;
80+
```
5481

55-
declare(strict_types=1);
82+
### → Composer Script
5683

57-
use WayOfDev\PhpCsFixer\Config\ConfigBuilder;
58-
use WayOfDev\PhpCsFixer\Config\RuleSets\DefaultSet;
84+
- Add `scripts` section to `composer.json`:
85+
86+
```diff
87+
{
88+
"scripts": {
89+
+ "cs:diff": "php vendor/bin/php-cs-fixer fix --dry-run -v --diff",
90+
+ "cs:fix": "php vendor/bin/php-cs-fixer fix -v"
91+
}
92+
}
93+
```
5994

60-
require_once 'vendor/autoload.php';
95+
### → Git
6196

62-
return ConfigBuilder::createFromRuleSet(new DefaultSet())
63-
->inDir(__DIR__ . '/src')
64-
->inDir(__DIR__ . '/tests')
65-
->addFiles([__FILE__])
66-
->getConfig();
67-
```
97+
- Place `.build` folder file into `.gitignore`
98+
99+
```diff
100+
+/.build/
101+
/vendor/
102+
```
68103

69-
3. Place `.php-cs-fixer.cache` file into `.gitignore`
104+
### → GitHub Actions
105+
106+
To use in GitHub Actions, do...
70107

71108
<br>
72109

73110
## 💻 Usage
74111

75-
### → Running
76-
77112
Fix coding standards by simply running console command:
78113

114+
### → Directly
115+
79116
```bash
80-
php vendor/bin/php-cs-fixer fix -v
117+
vendor/bin/php-cs-fixer fix -v
81118
```
82119

83-
### → Using Makefile
84-
85-
To use with our `Makefile`:
86-
87-
1. Add `scripts` section to `composer.json`:
88-
89-
```json
90-
{
91-
"scripts": {
92-
"cs-fix": "php vendor/bin/php-cs-fixer fix -v",
93-
"cs-diff": "php vendor/bin/php-cs-fixer fix --dry-run -v --diff"
94-
}
95-
}
96-
```
120+
### → Via Composer Script
97121

98-
2. Use `Makefile` code to run PHP-CS-Fixer tests:
122+
To use via composer script commands:
99123

100-
```bash
101-
# Run inspections and fix code
102-
$ make cs-fix
103-
104-
# Check coding standards without applying the fix
105-
$ make cs-diff
106-
```
124+
- Fixes code to follow coding standards using php-cs-fixer:
107125

108-
<br>
126+
```bash
127+
composer cs:diff
128+
```
109129

110-
## 🧪 Running Tests
130+
- Runs php-cs-fixer in dry-run mode and shows diff which will by applied:
111131

112-
### → PHPUnit tests
132+
```bash
133+
composer cs:fix
134+
```
113135

114-
To run tests, run the following command:
136+
### → Using Makefile
115137

116-
```bash
117-
make test
118-
```
138+
**To use with `Makefile`**
119139

120-
### → Static Analysis
140+
- Fixes code to follow coding standards using php-cs-fixer:
121141

122-
Code quality using PHPStan:
142+
```bash
143+
make lint-php
144+
```
123145

124-
```bash
125-
make stan
126-
```
146+
- Runs php-cs-fixer in dry-run mode and shows diff which will by applied:
127147

128-
### → Coding Standards Fixing
129-
130-
Fix code using The PHP Coding Standards Fixer (PHP CS Fixer) to follow our standards:
131-
132-
```bash
133-
make cs-fix
134-
```
148+
```bash
149+
make lint-diff
150+
```
135151

136152
<br>
137153

@@ -158,9 +174,11 @@ You are more than welcome. Before contributing, kindly check our [contribution g
158174

159175
## 🫡 Contributors
160176

161-
<a href="https://github.com/wayofdev/php-cs-fixer-config/graphs/contributors">
162-
<img align="left" src="https://img.shields.io/github/contributors-anon/wayofdev/php-cs-fixer-config?style=for-the-badge" alt="Contributors Badge"/>
163-
</a>
177+
<p align="left">
178+
<a href="https://github.com/wayofdev/php-cs-fixer-config/graphs/contributors">
179+
<img align="left" src="https://img.shields.io/github/contributors-anon/wayofdev/php-cs-fixer-config?style=for-the-badge" alt="Contributors Badge"/>
180+
</a>
181+
</p>
164182

165183
<br>
166184

composer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
"description": "Package adds custom rule-sets to php-cs-fixer",
44
"license": "MIT",
55
"type": "library",
6+
"keywords": [
7+
"php-cs-fixer",
8+
"php-cs-fixer-config",
9+
"php-cs-fixer-rules",
10+
"configuration",
11+
"code-style",
12+
"code-standards",
13+
"code-quality",
14+
"php",
15+
"static-analysis"
16+
],
617
"authors": [
718
{
819
"name": "Andrij Orlenko",

0 commit comments

Comments
 (0)