PHPackages                             lcobucci/behat-di-builder-extension - 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. lcobucci/behat-di-builder-extension

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

lcobucci/behat-di-builder-extension
===================================

A behat extension that allows injecting services from a container created with lcobucci/di-builder in contexts

1.3.0(4y ago)136.4k[1 issues](https://github.com/lcobucci/behat-di-builder-extension/issues)[8 PRs](https://github.com/lcobucci/behat-di-builder-extension/pulls)1MITPHPPHP ^8.0CI passing

Since Nov 27Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/lcobucci/behat-di-builder-extension)[ Packagist](https://packagist.org/packages/lcobucci/behat-di-builder-extension)[ GitHub Sponsors](https://github.com/lcobucci)[ Patreon](https://www.patreon.com/lcobucci)[ RSS](/packages/lcobucci-behat-di-builder-extension/feed)WikiDiscussions 1.4.x Synced today

READMEChangelog (5)Dependencies (9)Versions (21)Used By (1)

lcobucci/di-builder extension for behat
=======================================

[](#lcobuccidi-builder-extension-for-behat)

[![Total Downloads](https://camo.githubusercontent.com/ebd9158e1354d20f6ae2a2bb39023cafb68c4b2a7f58981aceca0661b654e8ae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c636f62756363692f62656861742d64692d6275696c6465722d657874656e73696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lcobucci/behat-di-builder-extension)[![Latest Stable Version](https://camo.githubusercontent.com/c6976fa34aa9dd2f95310abf2c8b2fa631cf695db6cdb57adff6c9cb69549607/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c636f62756363692f62656861742d64692d6275696c6465722d657874656e73696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lcobucci/behat-di-builder-extension)[![Unstable Version](https://camo.githubusercontent.com/b0a58ff983169a7fe28ad65edeabd5f2056679da10aadbf49fed8afeff312714/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f6c636f62756363692f62656861742d64692d6275696c6465722d657874656e73696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lcobucci/behat-di-builder-extension)

[![Build Status](https://camo.githubusercontent.com/62c377247d8467eb044c7f4eb0bf570ed9632e9f4b917ff26abc91183bd4f27d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c636f62756363692f62656861742d64692d6275696c6465722d657874656e73696f6e2f706870756e69742e796d6c3f6272616e63683d312e342e78267374796c653d666c61742d737175617265)](https://github.com/lcobucci/behat-di-builder-extension/actions?query=workflow%3A%22PHPUnit%20Tests%22+branch%3A1.2.x)[![Code Coverage](https://camo.githubusercontent.com/b686a0e75e98670ae4fe8f25cdf0f691c6f5819feaa5d7ce1bb758d195961e49/68747470733a2f2f636f6465636f762e696f2f67682f6c636f62756363692f62656861742d64692d6275696c6465722d657874656e73696f6e2f6272616e63682f312e322e782f67726170682f62616467652e737667)](https://codecov.io/gh/lcobucci/behat-di-builder-extension)

Allows injecting services from a container created using [`lcobucci/di-builder`](http://packagist.org/packages/lcobucci/di-builder)in a Behat context.

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

[](#installation)

Package is available on [Packagist](http://packagist.org/packages/lcobucci/behat-di-builder-extension), you can install it using [Composer](http://getcomposer.org).

```
composer require --dev lcobucci/behat-di-builder-extension
```

Basic usage
-----------

[](#basic-usage)

You must first enable the extension on your behat configuration file:

```
default:
  # ...

  extensions:
      Lcobucci\DependencyInjection\Behat\BuilderExtension: ~
```

Then enable the use of the test container (create by the extension) in the suite configuration:

```
default:
  suites:
    my-suite:
      services: "@test_container"

  extensions:
      Lcobucci\DependencyInjection\Behat\BuilderExtension: ~
```

And finally inject the services into your contexts

```
default:
  suites:
    my-suite:
      services: "@test_container"
      contexts:
        - My\Lovely\Context:
          - "@my_service"

  extensions:
    Lcobucci\DependencyInjection\Behat\BuilderExtension: ~
```

Advanced configuration
----------------------

[](#advanced-configuration)

You can provide the following parameters to the extension to better configure it:

- **name**: if you already have an extension using `test_container`
- **container\_builder**: if your application already uses `lcobucci/di-builder` and you want to use it (instead of a blank container builder)
- **packages**: so that you can add/override service definitions for testing

Your `behat.yml` would look like this with those settings:

```
default:
  suites:
    my-suite:
      services: "@my_container"
      contexts:
        - My\Lovely\Context:
          - "@my_service"

  extensions:
    Lcobucci\DependencyInjection\Behat\BuilderExtension:
      name: "my_container"
      container_builder: "config/container_builder.php"
      packages:
        My\DIBuilder\Package: ~
        My\DIBuilder\PackageWithConstructorArguments:
          - "one"
          - "two"
```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance40

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~261 days

Recently: every ~314 days

Total

11

Last Release

474d ago

Major Versions

0.1.x-dev → 1.0.02020-02-26

PHP version history (5 changes)0.1.0PHP ^7.1

1.0.0PHP ^7.4

1.2.0PHP ^7.4 || ^8.0

1.3.0PHP ^8.0

1.4.x-devPHP ~8.2.0 || ~8.3.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/201963?v=4)[Luís Cobucci](/maintainers/lcobucci)[@lcobucci](https://github.com/lcobucci)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (380 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (341 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (272 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (139 commits)")[![lcobucci](https://avatars.githubusercontent.com/u/201963?v=4)](https://github.com/lcobucci "lcobucci (121 commits)")

---

Tags

hacktoberfest

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/lcobucci-behat-di-builder-extension/health.svg)

```
[![Health](https://phpackages.com/badges/lcobucci-behat-di-builder-extension/health.svg)](https://phpackages.com/packages/lcobucci-behat-di-builder-extension)
```

###  Alternatives

[drupal/drupal-extension

Drupal extension for Behat

22215.1M147](/packages/drupal-drupal-extension)[friends-of-behat/symfony-extension

Integrates Behat with Symfony.

48223.4M551](/packages/friends-of-behat-symfony-extension)[friends-of-behat/variadic-extension

Variadic support for behat context arguments

2286.0M446](/packages/friends-of-behat-variadic-extension)[friends-of-behat/mink-extension

Mink extension for Behat

14034.2M467](/packages/friends-of-behat-mink-extension)[friends-of-behat/suite-settings-extension

Allows to overwrite suites' default settings.

2154.1M387](/packages/friends-of-behat-suite-settings-extension)[wp-cli/wp-cli-tests

WP-CLI testing framework

422.7M87](/packages/wp-cli-wp-cli-tests)

PHPackages © 2026

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