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 projects, supporting specification-by-example workflows. Aligns with roadmaps for test automation, QA collaboration, or product discovery where non-technical stakeholders define requirements in plain-text .feature files.

  • Build vs. Buy: Buy for teams already using Behat or needing a lightweight, PHP-native Gherkin parser. Build only if requiring custom parsing logic beyond Gherkin’s standard (e.g., domain-specific syntax extensions). Avoid reinventing parsing logic for tables, scenarios, or tags—this package handles edge cases (e.g., multilingual keywords, invalid tags) out-of-the-box.

  • Use Cases:

    • Test Automation: Parse .feature files into structured ASTs for Behat, Pest BDD, or custom test runners.
    • Living Documentation: Extract scenario outlines/examples to generate API docs (e.g., Swagger) or user manuals.
    • Localization: Support 40+ languages (e.g., "Given" → "Gangway!" for pirate-themed projects) without manual translations.
    • CI/CD Validation: Enforce Gherkin syntax rules (e.g., reject files ending with tags) via pre-commit hooks or CI pipelines.
    • Hybrid Workflows: Bridge Gherkin files with PHP services (e.g., parse scenarios → trigger microservices via HTTP).
  • Roadmap Enablers:

    • Gherkin 3.2 Compatibility: Future-proofs projects with experimental gherkin-32 mode for parity with Cucumber’s parser.
    • Extensibility: Deprecated Lexer/Parser classes hint at a modular architecture for custom dialects (e.g., DialectProviderInterface).
    • Performance: PHP 8.5 support and PHPStan-level 10 compliance reduce technical debt for long-term maintenance.

When to Consider This Package

Adopt if:

  • Your team uses Gherkin syntax (.feature files) and needs a PHP-native parser (e.g., for Behat, custom BDD tools, or documentation generators).
  • You require multilingual support (40+ languages) or edge-case handling (e.g., invalid tags, nested tables).
  • You’re building a test automation framework, living documentation tool, or specification-driven workflow where parsing .feature files is a core requirement.
  • You need compatibility with Cucumber’s parser (via gherkin-32 mode) or want to enforce Gherkin syntax rules in CI/CD.

Look elsewhere if:

  • You need JavaScript/TypeScript support (use @cucumber/cucumber or gherkin npm package).
  • Your use case requires custom syntax beyond Gherkin (e.g., domain-specific languages). Consider a custom lexer/parser or a package like Parsedown for Markdown.
  • You’re parsing non-Gherkin files (e.g., YAML, JSON). This package is Gherkin-specific.
  • Your team lacks PHP expertise or prefers managed services (e.g., Sauce Labs, BrowserStack for BDD testing).
  • You need real-time collaboration (e.g., live Gherkin editing). Pair with a tool like SpecFlow or Cucumber Live.

How to Pitch It (Stakeholders)

For Executives: "This package lets us standardize on Gherkin for requirements and tests—reducing miscommunication between devs, QA, and product teams. By parsing .feature files into structured data, we can automate test generation, validate syntax in CI, and even auto-generate API docs. It’s a lightweight, PHP-native solution that aligns with our BDD roadmap, with zero vendor lock-in (MIT license). For example, a pirate-themed project could use ‘Ahoy matey!’ instead of ‘Feature’—showing how flexible this is for branding or localization. Maintenance is minimal since it’s actively updated (last release: May 2026) and backed by the Behat community."

For Engineers: *"This is the official Gherkin parser for PHP, used by Behat. It handles all edge cases (multilingual keywords, invalid tags, tables) and supports Gherkin 3.2 compatibility for future-proofing. Key benefits:

  • Zero dependencies beyond PHP 7.2+ (PHP 8.5 supported).
  • Structured AST output: Parse .feature files into FeatureNode, ScenarioNode, etc., for custom logic.
  • Extensible: Deprecated Lexer/Parser classes hint at a clean architecture for custom dialects.
  • CI-friendly: Enforce syntax rules (e.g., reject files ending with tags) via pre-commit hooks.
  • Performance: Optimized for speed (PHPStan level 10 compliance).

Example use case: If we’re building a test automation framework, this replaces manual parsing with a battle-tested library. For living docs, we can extract scenarios into Markdown. Avoid reinventing the wheel—this handles 40+ languages, nested tables, and complex tag expressions out-of-the-box."*

For QA/Product Teams: *"This tool helps us write requirements in plain English (Gherkin) and automatically turn them into tests or docs. No more translation between spreadsheets and code—everyone works from the same .feature files. For example:

  • Collaboration: Non-technical team members can define ‘happy paths’ in Gherkin.
  • Validation: CI can flag syntax errors (e.g., missing Scenario keywords).
  • Localization: Support multiple languages without extra work. We’re not locked into a single tool—this parser works with Behat, custom scripts, or even API documentation generators."*
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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle