PHPackages                             bex/behat-extension-driver-locator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. bex/behat-extension-driver-locator

ActiveLibrary[Testing &amp; Quality](/categories/testing)

bex/behat-extension-driver-locator
==================================

Driver locator tool for behat extensions

2.0.1(6y ago)385.2M↓20.5%4MITPHPPHP &gt;=5.4

Since Nov 13Pushed 6y ago1 watchersCompare

[ Source](https://github.com/tkotosz/behat-extension-driver-locator)[ Packagist](https://packagist.org/packages/bex/behat-extension-driver-locator)[ Docs](https://github.com/tkotosz/behat-extension-driver-locator)[ RSS](/packages/bex-behat-extension-driver-locator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (3)Versions (6)Used By (4)

Behat-ExtensionDriverLocator
============================

[](#behat-extensiondriverlocator)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/2386d8678067aa8ace9d39ca45066e74f9f1cd1b21b794428735ea023c10895e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746b6f746f737a2f62656861742d657874656e73696f6e2d6472697665722d6c6f6361746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/tkotosz/behat-extension-driver-locator/?branch=master)[![Build Status](https://camo.githubusercontent.com/5e314c85bbb7bfb33912df2044566e331e749a0285363bbe989d7a1bb1464da2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746b6f746f737a2f62656861742d657874656e73696f6e2d6472697665722d6c6f6361746f722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/tkotosz/behat-extension-driver-locator/build-status/master)[![Build Status](https://camo.githubusercontent.com/9020bd35d82c9f02a3f17dfa012ba7d3f48b49fe5fc37c347667ed79c6a850bc/68747470733a2f2f7472617669732d63692e6f72672f746b6f746f737a2f62656861742d657874656e73696f6e2d6472697665722d6c6f6361746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/tkotosz/behat-extension-driver-locator)

Behat-ExtensionDriverLocator helps you load external drivers/services (like image uploaders, output formatters, etc) dinamically. The DriverLocator can find you a service in a preconfigured namespace by a given driverkey.

- It validates that the class implements the DriverInterface or your specific interface.
- It will call the configure method of the driver to get the config tree of the driver specific configurations
- It will validate the loaded config against the provided config tree.
- It will pass the valid config and the DI container to the load method of the driver in order to get a properly loaded service. The package also provide a Driver Node Builder which can create the drivers node for your behat extension. (see usage below)

Installation
------------

[](#installation)

Install by adding to your `composer.json`:

```
composer require --dev bex/behat-extension-driver-locator
```

Usage
-----

[](#usage)

1. In your behat extension's configure method use the Driver Node Builder to build the drivers configuration node:

    ```
        $driverNodeBuilder = DriverNodeBuilder::getInstance($driverNamespace, $driverParent);
        $driverNodeBuilder->buildDriverNodes($builder, $activeDriversNodeName, $driversCofigurationNodeName, $defaultDriverKeys);
    ```

    where:

    - the `$driverNamespace` is the namespace where the DriverNodeBuilder should look for the drivers when validating a given driver key e.g.: `My\\Awesome\\BehatExtension\\Driver`
    - the `$driverParent` is the parent class/interface which should be implemented by all driver e.g.: `My\\Awesome\\BehatExtension\\Driver\\MyAwesomeDriverInterface`(note that all driver need to implement the `Bex\Behat\ExtensionDriverLocator\DriverInterface`)
    - the `$builder` is an `Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition` instance which you get in your behat extension's configure method as a parameter, the DriverNodeBuilder will add the drivers node to this builder.
    - the `$activeDriversNodeName` is the name of the node where the user will be able to specify which driver should be used for your extension e.g.: `active_my_awesome_drivers`
    - the `driversCofigurationNodeName` is the name of the drivers node, the additional configuration of all driver will be under this node e.g.: `my_awesome_drivers`
    - the `$defaultDriverKeys` is the driverkey of the default driver(s) which will be used when the config is empty in the behat.yml e.g.: `first_awesomeness`
    - Note: The driverkey is always the lowercased and underlined version of the driver's classname. e.g. FirstAwesomeness -&gt; first\_awesomeness e.g. First -&gt; first

    With the example configurations a valid config would look like this:

    ```
    default:
      extensions:
       My\\Awesome\\BehatExtension: ~
    ```

    or

    ```
    default:
      extensions:
       My\\Awesome\\BehatExtension:
         active_my_awesome_drivers: first_awesomeness
         my_awesome_drivers:
           first_awesomeness:
             # ... all driver specific configuration goes here ...
    ```
2. In your behat extension's load method use the Driver Locator to load the active driver(s): Note that it will validate the driver specific configs automatically.

    ```
        $driverLocator = DriverLocator::getInstance($driverNamespace, $driverParent);
        $drivers = $driverLocator->findDrivers($container, $activeDrivers, $driverConfigs);
    ```

    where:

    - the `$driverNamespace` is the namespace where the DriverLocator should look for the drivers e.g.: `My\\Awesome\\BehatExtension\\Driver`
    - the `$driverParent` is the parent class/interface which should be implemented by all driver e.g.: `My\\Awesome\\BehatExtension\\Driver\\MyAwesomeDriverInterface`
    - the `$container` is an `Symfony\Component\DependencyInjection\ContainerBuilder` instance which you get in your behat extension's load method as a parameter, the DriverLocator will pass this container to the load method of each driver
    - the `$activeDrivers` are the active image drivers from the $config param which you get in the load method e.g.: $config\['active\_my\_awesome\_drivers'\]
    - the `$driverConfigs` are the driver specific configuration values from the $config param e.g.: $config\['my\_awesome\_drivers'\]

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity50

Moderate usage in the ecosystem

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~401 days

Total

5

Last Release

2232d ago

Major Versions

1.0.2 → 2.0.02020-04-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/6451ac5fdc814bfa3aec1b3cf746fdb3ccec68ccbbe3a6f30b3b6c9266b0cb79?d=identicon)[tkotosz](/maintainers/tkotosz)

---

Tags

BDDTDDBehat

### Embed Badge

![Health badge](/badges/bex-behat-extension-driver-locator/health.svg)

```
[![Health](https://phpackages.com/badges/bex-behat-extension-driver-locator/health.svg)](https://phpackages.com/packages/bex-behat-extension-driver-locator)
```

###  Alternatives

[polishsymfonycommunity/symfony-mocker-container

Provides base Symfony dependency injection container enabling service mocking.

1468.0M237](/packages/polishsymfonycommunity-symfony-mocker-container)[ciaranmcnulty/behat-stepthroughextension

Extension for behat to help debug failing scenarios

601.6M5](/packages/ciaranmcnulty-behat-stepthroughextension)[dvdoug/behat-code-coverage

Generate Code Coverage reports for Behat tests

593.6M37](/packages/dvdoug-behat-code-coverage)[bex/behat-step-time-logger

Extension for behat to help find slow scenario steps by logging the step times

261.5M1](/packages/bex-behat-step-time-logger)[ezsystems/behat-screenshot-image-driver-cloudinary

Cloudinary image driver for bex/behat-screenshot behat extension

28992.5k16](/packages/ezsystems-behat-screenshot-image-driver-cloudinary)[polishsymfonycommunity/symfony2-mocker-extension

Behat extension for mocking services defined in the Symfony2 dependency injection container.

26253.1k4](/packages/polishsymfonycommunity-symfony2-mocker-extension)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
