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.
.feature files) for test automation. It aligns with test-driven development (TDD) and behavior-driven design (BDD) workflows.gherkin-32 modes for alignment with the official Cucumber parser, reducing parsing discrepancies.behat/gherkin).Behat\Gherkin\Parser)..feature files to enforce style guidelines (e.g., via Laravel’s artisan commands).Keywords). Requires migration effort if extending core classes.@wip vs. wip) may break existing tag-based test selection.gherkin-32 mode is not production-ready; use cautiously..feature files may impact memory usage (test ASTs can be verbose). Cache parsed files (e.g., Laravel’s file_cache or database).wip&&~slow)?.feature files will be parsed? Is caching required?composer require behat/gherkin.$this->app->bind(Behat\Gherkin\Parser::class, function ($app) {
$keywords = new Behat\Gherkin\Keywords\ArrayKeywords([
'en' => ['feature' => 'Feature', /* ... */],
]);
return new Behat\Gherkin\Parser(new Behat\Gherkin\Lexer($keywords));
});
.feature files:
use Behat\Gherkin\Parser;
use Symfony\Component\Console\Command\Command;
class ParseFeatureCommand extends Command {
protected function execute(InputInterface $input, OutputInterface $output) {
$parser = app(Parser::class);
$ast = $parser->parse(file_get_contents('features/example.feature'));
// Process AST (e.g., validate, generate reports)
}
}
.feature files to auto-generate test classes (e.g., via Laravel’s tests/Feature structure).behat/behat package.behat/gherkin-lint for static analysis in CI..feature files for deprecated syntax (e.g., tags without @).gherkin-32 mode if alignment with Cucumber is critical.Lexer/Parser extensions with ParserInterface.@-prefixed syntax (e.g., @wip&&~@slow).behat/gherkin:4.7.x (PHP 7.2+).behat/behat and behat/gherkin versions are compatible (check Behat’s docs).gherkin-32 mode, easing migration to other tools.behat/gherkin and bind to Laravel’s container..feature files..feature files.gherkin-32 mode for Cucumber parity.behat/gherkin for breaking changes (e.g., API deprecations).composer.json if stability is critical.ParserInterface, DialectProviderInterface).i18n.php or custom keywords if adding new languages.getFullText() (v4.17.0+) to inspect raw Gherkin syntax.file_cache or redis) to avoid reprocessing..feature files may hit memory limits. Use streaming parsers or chunked processing.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Invalid Gherkin |
How can I help you explore Laravel packages today?