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.
i18n.php) justifies adoption for global products or teams requiring non-English Gherkin syntax (e.g., Feature: "Características" in Spanish)..feature files into structured ASTs for Behat/BDD test suites.Adopt When:
gherkin-32 mode).Look Elsewhere When:
gherkin-lint).*"This is the official PHP parser for Gherkin, the language powering Behat and BDD workflows. By adopting it, we can:
gherkin-32 compatibility.*"Behat/Gherkin gives us:
.feature files with zero Ruby dependencies.FeatureNode, StepNode).ParserInterface or DialectProviderInterface.gherkin-lint for real-time feedback.*"Key Perks:
composer require behat/gherkin + 2 lines of code to parse .feature files.getFullText() on StepNode shows exact syntax from feature files.gherkin-32 mode for future-proofing (aligns with Cucumber’s spec).
Example Use Case:$parser = new \Behat\Gherkin\Parser(new \Behat\Gherkin\Lexer($keywords));
$ast = $parser->parse(file_get_contents('login.feature'));
// Now $ast is a tree of Feature/Scenario/Step nodes you can traverse!
Gotchas:
Lexer/Parser directly (use ParserInterface).en)."*How can I help you explore Laravel packages today?