Download the PHP package roave/behat-psr11extension without Composer
On this page you can find all versions of the php package roave/behat-psr11extension. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download roave/behat-psr11extension
More information about roave/behat-psr11extension
Files in roave/behat-psr11extension
Package behat-psr11extension
Short Description PSR-11 Container extension for Behat
License MIT
Informations about the package behat-psr11extension
PSR-11 Container extension for Behat
Allows injecting services from a PSR-11-compatibile container in a Behat context.
Created with lots of help from @ciaranmcnulty.
Usage
First require the extension and dependencies with Composer:
First, if you don't already have one, create a file that will be included by the extension that returns a PSR-11
compatible container, for example using Laminas\ServiceManager
:
Then enable the extension in behat.yml
:
Then enable the use of the psr_container
service container (this is provided by the extension) in your behat.yml
suite configuration, for example:
And finally, add the names of any services required by your contexts in behat.yml
, for example:
You can also use behat's built-in autowire feature, to automatically inject the dependencies to the context:
If for some reason you want to use a name other than psr_container
for the container (e.g. collision with another extension) this can
be overridden:
Just for clarity (and hopefully ease of understanding), this would be the equivalent of doing this in plain PHP:
All versions of behat-psr11extension with dependencies
behat/behat Version ^3.14.0
psr/container Version ^1.1.2
symfony/config Version ^6.0.19
symfony/dependency-injection Version ^6.0.20