Freedom251 › BDD Testing Tools
phpspec

What phpspec is
phpspec is a free PHP toolset for shaping code through specification-driven development. Its SpecBDD workflow starts by describing an object’s behavior, implementing enough code to satisfy that description, and then refactoring. The manual presents it for specifying how classes implement features at the implementation level. A describe command can generate specification and source class files using configured naming and path rules. Built-in matchers cover identity, comparisons, exceptions, types, object state, counts, iterables, and strings. Collaborator behavior can be specified with stubs for return values, mocks for expected calls, and spies for checking calls after execution. Settings can be stored in phpspec.yml, .phpspec.yml, or phpspec.yml.dist, including suites, paths, formatters, extensions, and bootstrapping. Built-in formatters include progress, html, pretty, junit, dot, and tap. Extensions can add formatters and custom matcher classes. phpspec is installed through Composer as a project development dependency and runs locally in a Linux, self-hosted setup.
Who it suits
phpspec suits PHP developers who want implementation-level behavior specifications and a SpecBDD workflow. It is designed for local Linux projects installed with Composer.
What it does well
- Free PHP toolset
- SpecBDD workflow guides implementation
- Generates spec and source files
- Matchers cover common value types
- Supports stubs, mocks, and spies
What to know first
- Requires PHP 5.6 or 7
- Linux and self-hosted setup
- No Gherkin support
- Installed through Composer
Limits
phpspec is free. Its installation instructions specify PHP 5.6 or 7, and Gherkin support is not provided.
Plans
| Plan | Billed and limits | Price |
|---|---|---|
| phpspec | PHP SpecBDD framework · installed as a project development dependency through Composer | Free |
As phpspec.net lists them, read 4 Oct 2026. The maker's own page has the final word.
Getting started
- Ensure PHP 5.6 or 7 is installed.
- Install phpspec and its dependencies through Composer as a project development dependency.
- Add project settings in phpspec.yml, .phpspec.yml, or phpspec.yml.dist if needed.
- Run the executable from the project's bin directory.
- Use the `describe` command to create spec and source class files according to configured naming and paths.
Verdict
phpspec provides a focused, free workflow for specifying PHP class behavior before and during implementation. Its generators, matchers, test doubles, configurable formatters, and extensions support structured local development.
Questions
Does phpspec cost anything?
No. The listed phpspec plan is free.
How is phpspec installed?
Install phpspec and its dependencies through Composer as a project development dependency, then run its executable from the project's bin directory.
Which PHP versions does the installation page call for?
It says to ensure PHP 5.6 or 7 is installed.
Can phpspec generate files?
Yes. Its `describe` command creates spec and source class files according to configured naming and path rules.
Does it support Gherkin?
No, Gherkin support is listed as unavailable.
Where can project settings and output format choices be configured?
Settings can go in phpspec.yml, .phpspec.yml, or phpspec.yml.dist. Built-in formatters include progress, html, pretty, junit, dot, and tap.
Facts from phpspec's own pages
- BDD workflow
- Its SpecBDD workflow describes an object's behavior, implements enough code to meet the specification, and then refactors the code. · phpspec.net, 4 Oct 2026
- Code generation
- The configuration page documents a describe command that creates spec and source class files according to configured naming and path rules. · phpspec.net, 4 Oct 2026
- Configuration
- Project settings can be supplied in phpspec.yml, .phpspec.yml, or phpspec.yml.dist, with options for suites, paths, formatters, extensions, and bootstrapping. · phpspec.net, 4 Oct 2026
- Distribution
- The official site directs users to install phpspec in a PHP project with Composer and run its executable from the project bin directory. · phpspec.net, 4 Oct 2026
- Extension support
- The manual says extensions can add formatters and register custom matcher classes. · phpspec.net, 4 Oct 2026
- Installation
- The manual says to install phpspec and its dependencies through Composer as a project development dependency. · phpspec.net, 4 Oct 2026
- Intended use
- The manual describes phpspec as a tool for specifying how classes implement features, at the implementation level. · phpspec.net, 4 Oct 2026
- Matchers
- The manual lists built-in matchers for identity, comparison, exceptions, types, object state, counts, iterables, and strings. · phpspec.net, 4 Oct 2026
- Output formats
- The configuration manual lists progress, html, pretty, junit, dot, and tap as built-in formatters. · phpspec.net, 4 Oct 2026
- PHP requirement
- The installation page says to ensure PHP 5.6 or 7 is installed. · phpspec.net, 4 Oct 2026
- Purpose
- phpspec is a PHP toolset for driving emergent design by specification. · phpspec.net, 4 Oct 2026
- Test doubles
- The manual documents using stubs to specify collaborator return values, mocks to expect calls, and spies to check calls after behavior runs. · phpspec.net, 4 Oct 2026
Where phpspec stands on Freedom251
- BDD Testing Tools#20 of 30