Skip to content

Commit e619628

Browse files
committed
docs: adding readme
1 parent 996d79d commit e619628

File tree

2 files changed

+78
-6
lines changed

2 files changed

+78
-6
lines changed

.php-cs-fixer.dist.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
declare(strict_types=1);
44

5+
use WayOfDev\PhpCsFixer\Config\ConfigBuilder;
56
use WayOfDev\PhpCsFixer\Config\RuleSets\DefaultSet;
67

78
require_once 'vendor/autoload.php';
89

9-
$config = WayOfDev\PhpCsFixer\Config\ConfigBuilder::createFromRuleSet(new DefaultSet())
10+
$config = ConfigBuilder::createFromRuleSet(new DefaultSet())
1011
->inDir(__DIR__ . '/src')
1112
->inDir(__DIR__ . '/tests')
1213
->addFiles([__FILE__])

README.md

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<br>
22

33
<div align="center">
4-
<img width="456" src="https://raw.githubusercontent.com/wayofdev/ansible-role-tpl/master/assets/logo.gh-light-mode-only.png#gh-light-mode-only">
5-
<img width="456" src="https://raw.githubusercontent.com/wayofdev/ansible-role-tpl/master/assets/logo.gh-dark-mode-only.png#gh-dark-mode-only">
4+
<img width="456" src="https://raw.githubusercontent.com/wayofdev/php-cs-fixer-config/master/assets/logo.gh-light-mode-only.png#gh-light-mode-only">
5+
<img width="456" src="https://raw.githubusercontent.com/wayofdev/php-cs-fixer-config/master/assets/logo.gh-dark-mode-only.png#gh-dark-mode-only">
66
</div>
77

88

@@ -20,9 +20,9 @@
2020

2121
<br>
2222

23-
# PHP Package Template
23+
# PHP CS Fixer Config
2424

25-
This is minimal PHP template which is used by other PHP projects in wayofdev organization.
25+
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.
2626

2727
If you **like/use** this package, please consider **starring** it. Thanks!
2828

@@ -35,11 +35,75 @@ If you **like/use** this package, please consider **starring** it. Thanks!
3535
Require as dependency:
3636

3737
```bash
38-
$ composer req wayofdev/package-tpl
38+
$ composer req wayofdev/cs-fixer-config
3939
```
4040

4141
<br>
4242

43+
## 🛠 Configuration
44+
45+
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.
46+
47+
2. Example contents of `.php-cs-fixer.dist.php` file:
48+
49+
```php
50+
<?php
51+
52+
declare(strict_types=1);
53+
54+
use WayOfDev\PhpCsFixer\Config\ConfigBuilder;
55+
use WayOfDev\PhpCsFixer\Config\RuleSets\DefaultSet;
56+
57+
require_once 'vendor/autoload.php';
58+
59+
return ConfigBuilder::createFromRuleSet(new DefaultSet())
60+
->inDir(__DIR__ . '/src')
61+
->inDir(__DIR__ . '/tests')
62+
->addFiles([__FILE__])
63+
->getConfig();
64+
```
65+
66+
3. Place `.php-cs-fixer.cache` file into `.gitignore`
67+
68+
<br>
69+
70+
## 💻 Usage
71+
72+
### → Running
73+
74+
Fix coding standards by simply running console command:
75+
76+
```bash
77+
$ php vendor/bin/php-cs-fixer fix -v
78+
```
79+
80+
### → Using Makefile
81+
82+
To use with our `Makefile`:
83+
84+
1. Add `scripts` section to `composer.json`:
85+
86+
```json
87+
{
88+
"scripts": {
89+
"cs-fix": "php vendor/bin/php-cs-fixer fix -v",
90+
"cs-diff": "php vendor/bin/php-cs-fixer fix --dry-run -v --diff"
91+
}
92+
}
93+
```
94+
95+
2. Use `Makefile` code to run PHP-CS-Fixer tests:
96+
97+
```bash
98+
# Run inspections and fix code
99+
$ make cs-fix
100+
101+
# Check coding standards without applying the fix
102+
$ make cs-diff
103+
```
104+
105+
<br>
106+
43107
## 🧪 Running Tests
44108

45109
### → PHPUnit tests
@@ -80,3 +144,10 @@ Created in **2022** by [lotyp / wayofdev](https://github.com/wayofdev)
80144

81145
<br>
82146

147+
## 🧱 Resources
148+
149+
* Full documentation about all fixers are available here - [PHP-CS-Fixer configuration UI](https://mlocati.github.io/php-cs-fixer-configurator/#version:3.0)
150+
151+
* The official [PHP-CS-Fixer documentation](https://github.com/FriendsOfPHP/PHP-CS-Fixer)
152+
153+
<br>

0 commit comments

Comments
 (0)