Installation
Requirements
- PHP 8.5+
- Extensions:
dom,libxml,simplexml
Install
- Git
git clone https://github.com/php/docbook-cs.git
cd docbook-cs
Quick start
- New project
- GitHub Actions
- Changed files only
# Copy the dist config and run from the cloned repo
cp docbookcs.xml.dist docbookcs.xml
bin/docbook-cs
- uses: actions/checkout@v6
with:
repository: php/docbook-cs
path: docbook-cs
- uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
- run: docbook-cs/bin/docbook-cs --report=checkstyle --no-colors
Scan only the files touched by a pull request:
git diff origin/master...HEAD | bin/docbook-cs --diff --report=checkstyle
Options
| Option | Description |
|---|---|
--config=<file> | Path to configuration file (default: docbookcs.xml) |
--report=<format> | Output format: console (default), checkstyle, json |
--diff[=<file>] | Restrict analysis to lines changed in a unified diff. Pass - or omit the value to read from stdin. |
--colors | Force ANSI color output |
--no-colors | Disable ANSI color output |
-q, --quiet | Suppress progress output |
-v, --version | Show version and exit |
Exit codes
| Code | Meaning |
|---|---|
0 | No violations found |
1 | One or more violations found |
2 | Runtime error (bad config, unreadable file, etc.) |