Weave 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

Behat Messenger Context Laravel Package

macpaw/behat-messenger-context

Behat context for Symfony Messenger that lets you assert messages were dispatched, handled, or routed to specific transports during your scenarios. Integrates with Behat's step definitions to give readable, behavior-driven coverage of async messaging flows in PHP applications.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit — Unchanged by v3.1.0. The package remains a Behat extension supplying context classes around Symfony Messenger: it wires the message bus into BDD scenarios and exposes assertions that a message was dispatched, handled, or carried the expected envelope. Laravel's equivalents are Bus::fake(), Queue::fake(), and Event::fake() under Pest/PHPUnit. Laravel does not use Symfony Messenger — Illuminate\Bus and the Laravel Queue are separate implementations. Fit remains conceptual, not direct: the package is only usable if the application adopts Behat and Symfony Messenger, both foreign to a conventional Laravel stack. Fit for our context: low.

Integration feasibility — Composer-level integration is still trivial (MIT, small dependency graph, v3.1.0 is a minor, non-breaking release over v3.0.1). Runtime integration is where it breaks down, as before: you would need to (a) bootstrap Behat into the Laravel app, (b) install and bind Symfony Messenger alongside Laravel's own bus, and (c) route the tested domains through Messenger rather than Laravel's dispatcher. That means two message buses in one container — a persistent source of confusion and false-green tests. The new per-scenario queue reset does not address the dual-bus problem, only intra-suite state bleed.

Technical risk

  • Adoption risk: Still minimal community validation (low stars, no dependents, single-vendor MacPaw). v3.1.0 brings two first-time contributors, which is a marginal positive signal on project activity and bus factor, but governance and roadmap remain vendor-controlled.
  • Coupling risk: Unchanged. Tightly bound to Symfony Messenger's API (Envelope, transports, stamps). Symfony majors move with the framework, and Laravel pins symfony/* ranges in its own composer.json — constraint conflicts remain likely at every Laravel upgrade.
  • Behavioral risk: Improved. v3.1.0 adds a "reset message queues before scenario" hook, which directly mitigates the prior failure mode of state leaking between scenarios and producing order-dependent results. Residual risk: reset semantics are Messenger-transport-scoped and must be validated against whichever transport we configure (in-memory vs. async), and it does not reconcile Laravel's queue state with Messenger's.
  • Mitigating factor: Small, MIT-licensed, thin surface area — still cheap to vendor or fork. The added hook is a few lines we could replicate locally if we ever adopt Path B.

Key questions

  1. Do we need BDD/Gherkin at all, or is this a translation of a Symfony team's existing convention?
  2. Is there an existing Behat suite, or would this be greenfield tooling?
  3. Would we accept Symfony Messenger as a second bus, or is the real goal only the assertion pattern?
  4. Which modules would use Messenger vs. Laravel's Bus, and how do we prevent overlap?
  5. What is the CI cost of maintaining a parallel Behat suite?
  6. Who owns a fork if upstream stalls?
  7. New: Does the v3.1.0 queue reset cover all configured transports (in-memory, Doctrine, AMQP) and coexist with the container reboot between scenarios, or does it leave residual messages for async transports?

Integration Approach

Stack fit — Unchanged. Poor as a drop-in; good as a pattern donor. The value is the assertion API shape (assert dispatched count, assert handled, assert envelope contents), which maps cleanly onto Laravel's Bus::fake()/Queue::fake() assertions (assertDispatched, assertPushed, assertNothingDispatched). The v3.1.0 reset hook has a direct Laravel analogue: fakes are already re-instantiated per test method, so Laravel-native fakes get scenario isolation for free — reinforcing that Path A delivers the same guarantee without new tooling.

Migration path — Two viable routes, unchanged:

  • Path A (recommended): Do not install. Implement equivalent assertions over Laravel's fakes in Pest/PHPUnit — or in a thin custom Behat context if Behat is already mandated. Days of effort, no new runtime dependency.
  • Path B (only if the organization standardizes on Behat across Symfony and Laravel services): Install Behat with a Laravel bootstrap extension, add Symfony Messenger scoped to one bounded module, then add this context. Treat it as a proof of concept, not a production dependency. v3.1.0 slightly lowers the cost of Path B by removing hand-rolled queue cleanup between scenarios.

Compatibility — Verify the Symfony version matrix first. Laravel 10/11 pin Symfony components to 6.x/7.x ranges; confirm symfony/messenger satisfies existing constraints before adding anything. Check PHP version support against the runtime. Behat 3.x is stable but a quiet ecosystem compared with Pest/PHPUnit. v3.1.0 is a minor release with no documented breaking changes or deprecations, so no upgrade work is implied if the package were already in use — we are not using it, so this is informational only.

Sequencing

  1. Settle the testing-strategy decision (Behat vs. Pest/PHPUnit) — this gates everything downstream.
  2. If Behat: spike a minimal Laravel bootstrap extension and get one context running against a fake bus.
  3. Prototype a Symfony Messenger transport wired into the Laravel container for one module; measure whether it duplicates Illuminate\Bus confusingly.
  4. Only then compare macpaw/behat-messenger-context against a ~100-line local context — now including the reset hook (PR #41) as part of the build-vs-buy surface.
  5. Roll out module by module; keep Laravel-native fakes as the default everywhere else.

Operational Impact

Maintenance — Still low if used as-is: small, MIT, thin. The real cost remains upstream drift with no dependents to surface breakage early. Plan to vendor or fork, and budget a review at every Symfony/Laravel major bump. v3.1.0 is additive and low-churn; two new contributors reduce (but do not eliminate) the single-maintainer exposure.

Support — Single-vendor (MacPaw), no commercial support, no dependent ecosystem to consult. Internal knowledge must be built and documented; the team's Behat and Symfony Messenger expertise is the actual dependency, not the package. The v3.1.0 docs update is a small plus for onboarding but does not create a support channel.

Scaling — Unchanged in principle: the concern is test-suite scaling, not runtime. Behat suites are slower and less parallel-friendly than Pest/PHPUnit in typical Laravel CI, and a second framework doubles the tooling surface (two runners, two assertion styles, two CI stages). v3.1.0's per-scenario reset meaningfully improves reliability of parallel/sharded runs by preventing cross-scenario message bleed, but does not change the runner-cost profile.

Failure modes

  • Composer constraint conflict on symfony/messenger blocking a Laravel upgrade.
  • Dual-bus confusion: message dispatched on Laravel's bus but asserted against Messenger (or the reverse) → false-green tests.
  • Async transport in CI → intermittent failures; retries masking real defects. Partially mitigated by v3.1.0's queue reset; residual risk remains wherever a real (non-in-memory) transport is exercised, and where Laravel queue state is not reset alongside Messenger's.
  • Upstream abandonment → fork burden lands on an already-small team. Slightly reduced by broader contributor base.
  • Bootstrap drift between the Behat and PHPUnit environments → environment-specific passes.

Ramp-up — Unchanged. Behat + Gherkin + Symfony Messenger is three unfamiliar layers for a typical Laravel team. Realistic ramp-up is weeks for comfortable contribution, not days. That cost must be weighed against the package's narrow value: assertion sugar, now with scenario-reset convenience, over a message bus Laravel does not use.

Recommendation — Do not adopt as a production dependency. Harvest the assertion pattern into Laravel-native fakes (Bus::fake()/Queue::fake()), which delivers the same testing value — including automatic per-test isolation — at effectively zero integration and maintenance cost. v3.1.0 is a genuine quality-of-life improvement and a positive activity signal, but it reinforces rather than changes the conclusion. Revisit only if the organization commits to Behat as a cross-stack standard — and in that case, prototype behind a PoC branch with an explicit budget for a maintained fork.

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.
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle