behat/gherkin
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Behat/Gherkin is an innovative Domain Specific Language (DSL) parser for PHP. The main function of Behat/Gherkin is to read and interpret Gherkin code - an uncomplicated, natural language used mainly for behavior-driven development. It's an indispensable tool for applications that require BDD. Behat/Gherkin offers support for over 40 native languages, ensuring a clean, seamless architecture.
Using Behat/Gherkin involves coding with PHP. To use it, you will need to create a new instance of the Behat\Gherkin\Keywords\ArrayKeywords object with an associated array of keywords. Then, create an instance of the Behat\Gherkin\Lexer by passing the $keywords object in its constructor. A Behat\Gherkin\Parser instance is created subsequently, passing the $lexer object as the argument. The parse method of the Parser can be used to parse any Gherkin files. Here is a PHP code example of how to use Behat/Gherkin:
$keywords = new Behat\Gherkin\Keywords\ArrayKeywords(array(
'en' => array(
'feature' => 'Feature',
'background' => 'Background',
'scenario' => 'Scenario',
'scenario_outline' => 'Scenario Outline|Scenario Template',
'examples' => 'Examples|Scenarios',
'given' => 'Given',
'when' => 'When',
'then' => 'Then',
'and' => 'And',
'but' => 'But'
),
));
$lexer = new Behat\Gherkin\Lexer($keywords);
$parser = new Behat\Gherkin\Parser($lexer);
$feature = $parser->parse(file_get_contents('some.feature'));
Ensure that the 'some.feature' file is in the Gherkin format.
For comprehensive documentation about using Behat/Gherkin, a visit to the official Google Group at http://groups.google.com/group/behat is recommended. The group contains an assortment of resources, guidelines, and best practices that explain in depth how to make the most out of Behat/Gherkin. Additionally, for real-time interactions, you can connect with peers and experts on the #behat
channel on Freenode.