Skip to content
/ Gherkin Public

Gherkin parser, written in PHP for Behat project

License

Notifications You must be signed in to change notification settings

Behat/Gherkin

Folders and files

NameName
Last commit message
Last commit date
Jan 23, 2025
Feb 6, 2025
Feb 26, 2025
Feb 26, 2025
Dec 10, 2024
Dec 21, 2024
Jan 17, 2025
Dec 14, 2024
Dec 21, 2024
Feb 26, 2025
Dec 21, 2024
Sep 14, 2013
Dec 10, 2024
Feb 19, 2025
Oct 2, 2024
Feb 6, 2025
Feb 20, 2025

Repository files navigation

Behat Gherkin Parser

This is the php Gherkin parser for Behat. It comes bundled with more than 40 native languages (see i18n.php) support and clean architecture.

Useful Links

Usage Example

<?php

$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'
    ),
    'en-pirate' => array(
        'feature'          => 'Ahoy matey!',
        'background'       => 'Yo-ho-ho',
        'scenario'         => 'Heave to',
        'scenario_outline' => 'Shiver me timbers',
        'examples'         => 'Dead men tell no tales',
        'given'            => 'Gangway!',
        'when'             => 'Blimey!',
        'then'             => 'Let go and haul',
        'and'              => 'Aye',
        'but'              => 'Avast!'
    )
));
$lexer  = new Behat\Gherkin\Lexer($keywords);
$parser = new Behat\Gherkin\Parser($lexer);

$feature = $parser->parse(file_get_contents('some.feature'));

Installing Dependencies

curl https://getcomposer.org/installer | php
php composer.phar update

Contributors