CLI Reference
All commands and options available in bin/phpspec.
Commands
| Command | Description |
run [files] [options] | Load and execute specs and features |
describe <class> [-e method] | Generate a spec file |
exemplify <class> <method> | Add a method example to a spec |
pair [--prompt "..."] | Interactive AI pair programming REPL |
next | AI suggests what to describe or specify next |
refactor <target> | AI-powered behaviour-preserving refactoring |
Run examples
$ bin/phpspec run # all specs in spec/
$ bin/phpspec run spec/App/Calculator.spec.php # single spec
$ bin/phpspec run spec/App/Console # directory
$ bin/phpspec run features/ # all features
$ bin/phpspec run features/greeting.feature # single feature
Output format
| Option | Description |
-f, --format=FORMAT | pretty (default), dot, tap, junit |
-v | Verbose — shows per-example duration |
-q | Quiet — suppresses all output |
--profile[=N] | Show the N slowest examples (default: 10) |
Pretty (default)
phpspec run
Once you spec, you never go back!
Calculator
Calculator
✓ adds two numbers
✓ subtracts two numbers
1 spec
2 examples (2 passes)
Finished in 0.0042 seconds
Dot
One character per example: . pass, F failure, P pending, E error, S skipped.
$ bin/phpspec run --format dot
TAP
Test Anything Protocol output:
$ bin/phpspec run --format tap
JUnit XML
For CI integration:
$ bin/phpspec run --format junit > results.xml
Filtering & execution control
| Option | Description |
--filter=PATTERN | Only run specs whose path contains PATTERN |
--stop-on-failure | Stop after first failure or error |
--stop-on-error | Stop after first error |
--stop-on-warning | Stop after first warning |
--stop-on-deprecation | Stop after first deprecation |
--stop-on-notice | Stop after first notice |
--stop-on-skipped | Stop after first skip |
--stop-on-problems | Stop on any non-pass result |
--order=ORDER | default or random |
--seed=SEED | Seed for reproducible random order |
--story | Run only feature files |
--all | Run specs and features together |
$ bin/phpspec run --filter Calculator
$ bin/phpspec run --stop-on-failure
$ bin/phpspec run --order random --seed 42
Bootstrap
| Option | Description |
-b, --bootstrap=FILE | PHP file to require before running specs |
$ bin/phpspec run --bootstrap tests/bootstrap.php
Code generation
| Option | Description |
--fake | Generate method bodies with hardcoded return values from expectations |
Code coverage
| Option | Description |
--coverage | Text coverage report in terminal |
--coverage-html=DIR | HTML coverage report |
--coverage-clover=FILE | Clover XML for CI |
--coverage-min=PCT | Fail if coverage is below threshold (0–100) |
Coverage requires the xdebug extension with xdebug.mode=coverage.
Parallel execution
| Option | Description |
--parallel[=N] | Run specs across N worker processes (Fiber-based) |
$ bin/phpspec run --parallel
$ bin/phpspec run --parallel=4
Exit codes
| Code | Meaning |
0 | All examples passed |
1 | One or more examples failed or errored |