Behat
A behavior-driven development (BDD) testing framework for PHP driven by Gherkin.
Repository Health
Technical Analysis
Behat is a behavior-driven development (BDD) framework for PHP that lets teams describe application behavior in plain, human-readable Gherkin scenarios and then execute those scenarios as automated tests. Business stakeholders, testers, and developers share the same .feature files, and Behat maps each step to PHP step-definition methods in context classes.
Run from the command line via vendor/bin/behat, it discovers features, matches steps against your definitions, and reports which expectations pass or fail. Behat is heavily extensible through its Symfony-based service container, supports hooks, suites, profiles, and translations, and integrates with tools like Mink for web acceptance testing — making it the de facto standard for StoryBDD in the PHP ecosystem.
What You Get
- A CLI test runner (
vendor/bin/behat) that discovers and executes Gherkin.featurescenarios - Step definitions and context classes that map plain-language steps to PHP code
- Hooks, suites, and profiles for organizing and configuring test runs
- An extensible, Symfony-based architecture with extensions like Mink for web acceptance testing
Common Use Cases
- Writing acceptance tests as shared Gherkin scenarios between business and developers
- Driving end-to-end web tests through Mink and a browser or HTTP driver
- Documenting and verifying business rules as executable specifications
Under The Hood
Architecture — Behat is built around a Symfony service container assembled from extensions. The Gherkin package parses feature files into an AST; Behat’s Tester, Definition, Hook, and Context services (under src/Behat/) then match each scenario step to a step-definition method, invoke it, and collect results, which output formatters render. The bin/behat entry point boots the container from your behat.dist.php/behat.yml configuration and CLI options.
Tech Stack — Written in PHP on top of Symfony components (Console, DependencyInjection, EventDispatcher, Config) and the behat/gherkin parser. It is distributed via Composer and packaged as a PHAR through box.
Code Quality — The repository has an extensive tests/ suite plus a large features/ directory where Behat tests itself with its own Gherkin scenarios (dogfooding), and it enforces static analysis with PHPStan and refactoring rules via Rector — signaling a mature, well-maintained codebase.
API Design — Authors write natural-language Gherkin and annotate PHP context methods with step patterns, so the ‘API’ is largely declarative. Configuration through profiles and suites is flexible, and the extension system lets the tool grow (Mink, custom formatters) without changing test code.
Used by 3 apps in this directory
BillaBear
Ecommerce · Invoicing Finance
Self-hostable subscription management and billing platform with Stripe integration, tax automation, configurable workflows, and Twig-based document generation.
opencloud
File Storage
Open source file management and collaboration platform that keeps your data under your control, no database required.
Nextcloud Server
Collaboration · File Storage
Your own private cloud: self-hosted file sync, collaboration, and communication with no vendor lock-in.