Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b074153

Browse files
author
Patrick
committedJan 14, 2021
update docs
1 parent 13c39ac commit b074153

File tree

4 files changed

+154
-1
lines changed

4 files changed

+154
-1
lines changed
 

‎.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@ composer.lock
66
.php_cs.dist
77
/coverage
88
/scripts
9-
/docs
9+
/docs/*
10+
!/docs/automation.md
11+
!/docs/finders.md
12+
!/docs/rulesets/*.md
1013
.php_cs.ga.dist
14+

‎README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ The `custom` type will prompt you to enter the directory names you'd like `php-c
183183

184184
---
185185

186+
## Automatic Formatting
187+
188+
If you would like to automatically apply `php-cs-fixer` formatting using Github Actions, see the [automation with Github Actions](docs/automation.md) documentation.
189+
190+
---
191+
186192
## [Finder Presets](docs/finders.md)
187193

188194
#### `BasicProjectFinder`

‎docs/automation.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Automatic Code Formatting
2+
3+
If you'd like to automatically format your code whenever you push to your `main` branch, you can use the following Github Action workflow.
4+
5+
Save this file in your project directory as `.github/workflows/php-cs-fixer.yml`.
6+
7+
---
8+
9+
**This workflow makes several assumptions:**
10+
11+
- that your primary branch name is `main`, not something else such as `master`
12+
13+
- that your `php-cs-fixer` configuration file is named `.php_cs.dist`
14+
15+
If either of these differ from your setup, please adjust the workflow accordingly.
16+
17+
---
18+
19+
## `.github/workflows/php-cs-fixer.yml`
20+
21+
```yaml
22+
name: Check & fix styling
23+
24+
on:
25+
push:
26+
branches:
27+
- main
28+
29+
jobs:
30+
php-cs-fixer:
31+
32+
runs-on: ubuntu-latest
33+
strategy:
34+
fail-fast: false
35+
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v2
39+
with:
40+
ref: ${{ github.head_ref }}
41+
42+
- name: Setup PHP
43+
uses: shivammathur/setup-php@v2
44+
with:
45+
php-version: 7.4
46+
extensions: mbstring
47+
coverage: none
48+
tools: composer:v2
49+
50+
- name: Cache dependencies
51+
uses: actions/cache@v2
52+
with:
53+
path: ~/.composer/cache/files
54+
key: dependencies-php-7.4-composer-${{ hashFiles('composer.json') }}
55+
56+
- name: Install dependencies
57+
run: composer install --prefer-dist --no-interaction --optimize-autoloader
58+
59+
- name: Run PHP CS Fixer
60+
run: vendor/bin/php-cs-fixer fix --config=.php_cs.dist --allow-risky=yes
61+
62+
- name: Commit changes
63+
uses: stefanzweifel/git-auto-commit-action@v4
64+
with:
65+
commit_message: Fix styling
66+
```

‎docs/finders.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
## Finder Presets
2+
3+
---
4+
5+
#### [`BasicProjectFinder`](../src/Finders/BasicProjectFinder.php)
6+
7+
**Name:** `project`
8+
9+
**Features:**
10+
11+
- ignores VCS files
12+
- ignores dot files
13+
- includes PHP files
14+
- excludes `vendor/` directory
15+
16+
**Description:** basic project
17+
18+
**Example:**
19+
20+
```bash
21+
vendor/bin/pf-create-cs-config project
22+
```
23+
24+
#### [`LaravelProjectFinder`](../src/Finders/LaravelProjectFinder.php)
25+
26+
**Name:** `laravel`
27+
28+
**Features:**
29+
30+
- inherits [`BasicProjectFinder`](#basicprojectfinder) presets
31+
- excludes `*.blade.php` files
32+
- excludes all files in `bootstrap/`, `public/`, `resources/`, `storage/`
33+
- includes PHP files in `app/`, `config/`, `database/`, `routes/`, `tests/`
34+
35+
**Description:** standard laravel project
36+
37+
**Example:**
38+
39+
```bash
40+
vendor/bin/pf-create-cs-config laravel
41+
```
42+
43+
#### [`LaravelPackageFinder`](../src/Finders/LaravelPackageFinder.php)
44+
45+
**Name:** `laravel:package`
46+
47+
**Features:**
48+
49+
- inherits [`BasicProjectFinder`](#basicprojectfinder) presets
50+
- excludes `*.blade.php` files
51+
- excludes all files in `resources/`
52+
- includes PHP files in `src/`, `tests/`, `config/`
53+
54+
**Description:** standard laravel package
55+
56+
**Example:**
57+
58+
```bash
59+
vendor/bin/pf-create-cs-config laravel:package
60+
```
61+
62+
#### [`ComposerPackageFinder`](../src/Finders/ComposerPackageFinder.php)
63+
64+
**Name:** `package`
65+
66+
**Features:**
67+
68+
- inherits [`BasicProjectFinder`](#basicprojectfinder) presets
69+
- includes PHP files in `src/`, `tests/`
70+
71+
**Description:** standard composer package
72+
73+
**Example:**
74+
75+
```bash
76+
vendor/bin/pf-create-cs-config package
77+
```

0 commit comments

Comments
 (0)
Please sign in to comment.