CLI Reference

All commands and options available in bin/phpspec.

Commands

CommandDescription
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
nextAI 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

OptionDescription
-f, --format=FORMATpretty (default), dot, tap, junit
-vVerbose — shows per-example duration
-qQuiet — 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

OptionDescription
--filter=PATTERNOnly run specs whose path contains PATTERN
--stop-on-failureStop after first failure or error
--stop-on-errorStop after first error
--stop-on-warningStop after first warning
--stop-on-deprecationStop after first deprecation
--stop-on-noticeStop after first notice
--stop-on-skippedStop after first skip
--stop-on-problemsStop on any non-pass result
--order=ORDERdefault or random
--seed=SEEDSeed for reproducible random order
--storyRun only feature files
--allRun specs and features together
$ bin/phpspec run --filter Calculator
$ bin/phpspec run --stop-on-failure
$ bin/phpspec run --order random --seed 42

Bootstrap

OptionDescription
-b, --bootstrap=FILEPHP file to require before running specs
$ bin/phpspec run --bootstrap tests/bootstrap.php

Code generation

OptionDescription
--fakeGenerate method bodies with hardcoded return values from expectations

Code coverage

OptionDescription
--coverageText coverage report in terminal
--coverage-html=DIRHTML coverage report
--coverage-clover=FILEClover XML for CI
--coverage-min=PCTFail if coverage is below threshold (0–100)

Coverage requires the xdebug extension with xdebug.mode=coverage.

Parallel execution

OptionDescription
--parallel[=N]Run specs across N worker processes (Fiber-based)
$ bin/phpspec run --parallel
$ bin/phpspec run --parallel=4

Exit codes

CodeMeaning
0All examples passed
1One or more examples failed or errored