phpspec
SpecBDD framework for designing and testing PHP code
TLDR
SYNOPSIS
phpspec command [arguments] [options]
DESCRIPTION
phpspec is a SpecBDD (Specification Behaviour-Driven Development) tool for PHP. Rather than verifying existing implementations like a traditional unit test runner, it drives the design of objects: you write a spec describing how a class should behave, run phpspec, and it offers to scaffold the missing class, methods, and return statements for you.Specs are plain PHP classes that extend PhpSpec\\ObjectBehavior. Each `it*` / `its*` method is a single example. Collaborators are described as type-hinted parameters and phpspec automatically supplies prophecy-based test doubles for them.Configuration lives in `phpspec.yml` (or `phpspec.yml.dist`) at the project root and controls suites, bootstrap files, formatters, and matchers/extensions. PhpSpec is intentionally narrower than PHPUnit — it focuses on isolated, design-first object specs and pairs naturally with a higher-level acceptance tool such as Behat.
PARAMETERS
-c, --config FILE
Use a specific configuration file (default: phpspec.yml or phpspec.yml.dist).-f, --format NAME
Output formatter: progress (default), pretty, junit, dot, tap, html.--stop-on-failure
Halt the run as soon as a spec fails.--fake
Make generated dummy methods return realistic fake data.-n, --no-interaction
Do not ask any interactive questions; assume defaults.-v / -vv / -vvv
Increase verbosity. -vvv prints exception traces.--ansi / --no-ansi
Force or disable ANSI color output.-q, --quiet
Suppress all output.-V, --version
Display the phpspec version.
CONFIGURATION
phpspec.yml
Project configuration: declares suites, namespaces, source directories, formatter, and extensions.
COMMANDS
run [spec]
Run all specs (or a single spec file/class) and offer to generate missing code interactively.describe CLASS
Create a new spec file for the given fully qualified class name.help [command]
Show help for a specific command.list
List all available commands.
CAVEATS
PhpSpec is not a drop-in replacement for PHPUnit — it cannot test static methods, final classes (without extensions), or exercise framework-level integration. Generated code is intentionally minimal; you are expected to fill in the real implementation after scaffolding.
HISTORY
PhpSpec was started in 2007 by Marcello Duarte and rewritten as PhpSpec 2 in 2014 with help from Konstantin Kudryashov and the Behat community. It is maintained on GitHub under the `phpspec` organisation and is installable via Composer.
