talira

Specification-oriented BDD framework for PHP

open sourceMITfree

phpspec is a specification-oriented behaviour-driven development framework for PHP 8.3 and later: you describe how a class should behave in specs, and phpspec drives its design and can generate the code. Version 9 is a complete rewrite that replaces the ObjectBehavior base class with a closure-based DSL inspired by RSpec and Jasmine, and adds a pair programming mode in which an LLM writes specs, generates code and refactors, driven by your specifications.

Problems it solves

  • write behaviour-driven specs for my PHP classes before the code
  • let my PHP specs drive the design and generate class skeletons
  • an RSpec-style testing framework for PHP

Features

  • specification-oriented BDD
  • code generation from specs
  • closure-based DSL inspired by RSpec and Jasmine (v9)
  • AI pair programming mode

Alternatives

The same job

These do what phpspec does.

  1. Behat Behaviour-driven development for PHP
  2. Pest The elegant PHP testing framework
  3. PHPUnit The testing framework for PHP
  4. Codeception Full-stack testing framework for PHP

Compare phpspec with the top 3