Skip to content

Commit bd3801c

Browse files
committed
docs: updating readme
1 parent b39a817 commit bd3801c

File tree

2 files changed

+92
-62
lines changed

2 files changed

+92
-62
lines changed

README.md

Lines changed: 81 additions & 62 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,111 @@ 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
120+
### Via Composer Script
84121

85-
To use with our `Makefile`:
122+
To use via composer script commands:
86123

87-
1. Add `scripts` section to `composer.json`:
124+
* Fixes code to follow coding standards using php-cs-fixer:
88125

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-
```
126+
```bash
127+
composer cs:diff
128+
```
97129

98-
2. Use `Makefile` code to run PHP-CS-Fixer tests:
130+
* Runs php-cs-fixer in dry-run mode and shows diff which will by applied:
99131

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-
```
132+
```bash
133+
composer cs:fix
134+
```
107135

108-
<br>
109-
110-
## 🧪 Running Tests
111-
112-
### → PHPUnit tests
113-
114-
To run tests, run the following command:
115-
116-
```bash
117-
make test
118-
```
136+
### → Using Makefile
119137

120-
### → Static Analysis
138+
**To use with `Makefile`**
121139

122-
Code quality using PHPStan:
140+
- Fixes code to follow coding standards using php-cs-fixer:
123141

124-
```bash
125-
make stan
126-
```
142+
```bash
143+
make lint-php
144+
```
127145

128-
### → Coding Standards Fixing
146+
- Runs php-cs-fixer in dry-run mode and shows diff which will by applied:
129147

130-
Fix code using The PHP Coding Standards Fixer (PHP CS Fixer) to follow our standards:
148+
```bash
149+
make lint-diff
150+
```
131151

132-
```bash
133-
make cs-fix
134-
```
135152

136153
<br>
137154

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

159176
## 🫡 Contributors
160177

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>
178+
<p align="left">
179+
<a href="https://github.com/wayofdev/php-cs-fixer-config/graphs/contributors">
180+
<img align="left" src="https://img.shields.io/github/contributors-anon/wayofdev/php-cs-fixer-config?style=for-the-badge" alt="Contributors Badge"/>
181+
</a>
182+
</p>
164183

165184
<br>
166185

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)