behat/gherkin
behat/gherkin is a PHP library for parsing the Gherkin language used in BDD. Read and tokenize feature files, build an AST, and integrate with Behat or other test runners to execute human-readable scenarios in your test suite.
BDD (Behavior-Driven Development) Adoption: Enables teams to integrate Gherkin syntax parsing into PHP-based projects, supporting specification-by-example workflows. Aligns with roadmaps for test automation, QA collaboration, or product discovery where non-technical stakeholders define requirements in plain-text .feature files.
Build vs. Buy: Buy for teams already using Behat or needing a lightweight, PHP-native Gherkin parser. Build only if requiring custom parsing logic beyond Gherkin’s standard (e.g., domain-specific syntax extensions). Avoid reinventing parsing logic for tables, scenarios, or tags—this package handles edge cases (e.g., multilingual keywords, invalid tags) out-of-the-box.
Use Cases:
.feature files into structured ASTs for Behat, Pest BDD, or custom test runners.Roadmap Enablers:
gherkin-32 mode for parity with Cucumber’s parser.Lexer/Parser classes hint at a modular architecture for custom dialects (e.g., DialectProviderInterface).Adopt if:
.feature files) and needs a PHP-native parser (e.g., for Behat, custom BDD tools, or documentation generators)..feature files is a core requirement.gherkin-32 mode) or want to enforce Gherkin syntax rules in CI/CD.Look elsewhere if:
@cucumber/cucumber or gherkin npm package).For Executives:
"This package lets us standardize on Gherkin for requirements and tests—reducing miscommunication between devs, QA, and product teams. By parsing .feature files into structured data, we can automate test generation, validate syntax in CI, and even auto-generate API docs. It’s a lightweight, PHP-native solution that aligns with our BDD roadmap, with zero vendor lock-in (MIT license). For example, a pirate-themed project could use ‘Ahoy matey!’ instead of ‘Feature’—showing how flexible this is for branding or localization. Maintenance is minimal since it’s actively updated (last release: May 2026) and backed by the Behat community."
For Engineers: *"This is the official Gherkin parser for PHP, used by Behat. It handles all edge cases (multilingual keywords, invalid tags, tables) and supports Gherkin 3.2 compatibility for future-proofing. Key benefits:
.feature files into FeatureNode, ScenarioNode, etc., for custom logic.Lexer/Parser classes hint at a clean architecture for custom dialects.Example use case: If we’re building a test automation framework, this replaces manual parsing with a battle-tested library. For living docs, we can extract scenarios into Markdown. Avoid reinventing the wheel—this handles 40+ languages, nested tables, and complex tag expressions out-of-the-box."*
For QA/Product Teams:
*"This tool helps us write requirements in plain English (Gherkin) and automatically turn them into tests or docs. No more translation between spreadsheets and code—everyone works from the same .feature files. For example:
Scenario keywords).How can I help you explore Laravel packages today?