Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Gherkin Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • BDD (Behavior-Driven Development) Adoption: Enables teams to integrate Gherkin syntax parsing into PHP-based workflows, supporting feature-driven development and collaboration between technical/non-technical stakeholders. Aligns with roadmaps for automated testing frameworks (e.g., Behat, custom BDD tools) or documentation-as-code initiatives.
  • Localization & Multilingual Support: Built-in support for 40+ languages (via i18n.php) justifies adoption for global products or teams requiring non-English Gherkin syntax (e.g., Feature: "Características" in Spanish).
  • Build vs. Buy: Buy for teams already using Behat or needing a lightweight, PHP-native Gherkin parser without coupling to Ruby’s Cucumber. Build only if requiring custom syntax extensions beyond Gherkin’s spec.
  • Use Cases:
    • Test Automation: Parse .feature files into structured ASTs for Behat/BDD test suites.
    • CI/CD Integration: Validate Gherkin syntax in pre-commit hooks or pipeline gates (e.g., reject malformed feature files).
    • Custom Tools: Build domain-specific languages (DSLs) or specification generators using Gherkin as a foundation.
    • Legacy Migration: Replace Ruby/Cucumber dependencies in monolithic PHP apps with native PHP parsing.

When to Consider This Package

  • Adopt When:

    • Your team uses PHP/Behat and needs a reliable Gherkin parser (avoid reinventing the wheel).
    • You require multilingual support (e.g., non-English feature files).
    • You’re building a BDD toolchain or extending Behat’s ecosystem.
    • You need fine-grained control over parsing (e.g., custom dialects, experimental gherkin-32 mode).
    • Your project drops PHP <7.2 (minimum supported version).
  • Look Elsewhere When:

    • You’re using Ruby/Cucumber and prefer native Ruby parsers (avoid PHP interop overhead).
    • You need real-time Gherkin editing/validation (consider a web-based linter like gherkin-lint).
    • Your use case requires non-Gherkin DSLs (e.g., YAML/JSON schemas).
    • You lack PHP expertise to integrate lexer/parser components.
    • You need active maintenance guarantees beyond community-driven updates (though MIT license and active PRs mitigate this).

How to Pitch It (Stakeholders)

For Executives:

*"This is the official PHP parser for Gherkin, the language powering Behat and BDD workflows. By adopting it, we can:

  • Unify our testing ecosystem in PHP, reducing dependency sprawl (no Ruby/Cucumber).
  • Enable global teams to write specs in their native language (40+ supported).
  • Future-proof our BDD tools with experimental features like gherkin-32 compatibility.
  • Cut dev time by leveraging a battle-tested parser (used by Behat, 100K+ stars). Cost: Free (MIT license). ROI: Faster test automation, better collaboration, and scalable specs."*

For Engineering:

*"Behat/Gherkin gives us:

  • Native PHP parsing of .feature files with zero Ruby dependencies.
  • Structured ASTs for custom test runners or spec generators (e.g., FeatureNode, StepNode).
  • Extensibility: Override lexers/parsers via ParserInterface or DialectProviderInterface.
  • CI-friendly: Validate Gherkin syntax early (e.g., reject malformed files in pipelines).
  • Backward-compatible: Supports PHP 7.2+ and integrates with Composer. Tradeoffs:
  • No GUI/linter: Pair with gherkin-lint for real-time feedback.
  • Learning curve: Requires familiarity with Gherkin syntax and Behat’s architecture. Recommendation: Use for Behat/BDD projects; avoid for non-Gherkin use cases."*

For Developers:

*"Key Perks:

  • Plug-and-play: composer require behat/gherkin + 2 lines of code to parse .feature files.
  • Multilingual: Swap keywords dynamically (e.g., pirate-speak for fun, or Russian for work).
  • Debugging: getFullText() on StepNode shows exact syntax from feature files.
  • Experimental: 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:

  • Deprecations: Avoid extending Lexer/Parser directly (use ParserInterface).
  • Edge Cases: Handle invalid tags/language gracefully (e.g., fall back to en)."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium