PHPackages                             nicolasguilloux/phpunit-dependency-injection-bundle - 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. nicolasguilloux/phpunit-dependency-injection-bundle

ActiveSymfony-bundle[Testing &amp; Quality](/categories/testing)

nicolasguilloux/phpunit-dependency-injection-bundle
===================================================

A magic bundle

v1.1.0(3y ago)03071MITPHPPHP ^8.0 || ^7.4

Since Dec 23Pushed 3y ago1 watchersCompare

[ Source](https://github.com/NicolasGuilloux/phpunit-dependency-injection-bundle)[ Packagist](https://packagist.org/packages/nicolasguilloux/phpunit-dependency-injection-bundle)[ RSS](/packages/nicolasguilloux-phpunit-dependency-injection-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (11)Versions (5)Used By (1)

[![phpunit dependency injection bundle](https://camo.githubusercontent.com/d427b4eefe023700ff86d69b1b5599d349655949f0721fcd920247fc3a7871f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f4e69636f6c61734775696c6c6f75782f706870756e69742d646570656e64656e63792d696e6a656374696f6e2d62756e646c65)](https://packagist.org/packages/NicolasGuilloux/phpunit-dependency-injection-bundle)[![badge](https://github.com/NicolasGuilloux/phpunit-dependency-injection-bundle/workflows/Tests/badge.svg)](https://github.com/NicolasGuilloux/phpunit-dependency-injection-bundle/actions)[![badge](https://camo.githubusercontent.com/b8dc96fc9fedc55b8d5d9c68495d1241f1fc69ed0dc5dd958e4e417ee9ee0259/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4e69636f6c61734775696c6c6f75782f706870756e69742d646570656e64656e63792d696e6a656374696f6e2d62756e646c652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/NicolasGuilloux/phpunit-dependency-injection-bundle?branch=master)[![maintainability](https://camo.githubusercontent.com/de375f09c81c9cdddcb115dd7ca1afd788ed6be35437e7436b60df74b0fc1b4d/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f65393139636466626261303365353931613637652f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/NicolasGuilloux/phpunit-dependency-injection-bundle/maintainability)[![contributions welcome brightgreen](https://camo.githubusercontent.com/9e93e892d0685e1bf7a1d0bd7c8410d6ecf2086a0a7b48dd58a6b96fa556ea2a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6e747269627574696f6e732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/NicolasGuilloux/phpunit-dependency-injection-bundle/issues)[![license MIT blue](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP 7](https://camo.githubusercontent.com/f13cc5baf57b8e115f484fde3c7ade83b2a814edc6940da54ec35bac43eb3faf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e332532422d79656c6c6f77)](https://camo.githubusercontent.com/f13cc5baf57b8e115f484fde3c7ade83b2a814edc6940da54ec35bac43eb3faf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e332532422d79656c6c6f77)[![Symfony 4%2B black](https://camo.githubusercontent.com/c7f909c07c2aaac81c18968088fe3f5c9fc6348987b7f330e177fdcd24a1ea9e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d342532422d626c61636b)](https://camo.githubusercontent.com/c7f909c07c2aaac81c18968088fe3f5c9fc6348987b7f330e177fdcd24a1ea9e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d342532422d626c61636b)[![Symfony 5%2B black](https://camo.githubusercontent.com/0b1128137c1357779f86a0d8f2734fbb557fd154175959c66c0174bbf9e855e5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d352532422d626c61636b)](https://camo.githubusercontent.com/0b1128137c1357779f86a0d8f2734fbb557fd154175959c66c0174bbf9e855e5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d352532422d626c61636b)

Short description

Table of content
----------------

[](#table-of-content)

- [1. Installation](#installation)
- [2. Motivations](#motivations)
- [3. Documentation](#documentation)
    - [3.1. Configuration](#configuration)
- [4. Versioning](#versioning)
- [5. Contributing](#contributing)
- [6. License](#license)
- [7. Hacking](#hacking)

1. Installation
---------------

[](#1-installation)

Execute the composer command to install the bundle:

```
composer require nicolasguilloux/phpunit-dependency-injection-bundle --dev
```

Now add the configuration for the test environment and change it to your needs:

```
phpunit_dependency_injection:
    tests_namespace: 'App\Tests'
```

Now, it is just a matter of implementing the trait in the corresponding test in the `setUp` method.

Warning: Note that the class is still a TestCase, so you won’t be able to use the constructor to inject dependencies. This is where the `Required` annotation/attribute becomes handy. Checkout the [Symfony’s documentation](https://symfony.com/doc/current/service_container/calls.html).

```
use NicolasGuilloux\PhpunitDependencyInjectionBundle\TestCase\AutowiringTestTrait;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Contracts\Service\Attribute\Required;

final class RandomTest extends KernelTestCase
{
    use AutowiringTestTrait;

    #[Required]
    public LoggerInterface $logger;

    public function setUp(): void
    {
        parent::setUp();

        self::bootKernel();
        $this->autowire(self::getContainer());
    }

    public function testSomething(): void
    {
        self::assertInstanceOf(LoggerInterface::class, $this->logger);
    }
}
```

2. Motivations
--------------

[](#2-motivations)

Checkout the [Motivations article](./docs/Motivations.adoc).

3. Documentation
----------------

[](#3-documentation)

### 3.1. [Configuration](docs/Configuration.adoc)

[](#31-configuration)

4. Versioning
-------------

[](#4-versioning)

phpunit-dependency-injection-bundle follows [semantic versioning](https://semver.org/). In short the scheme is MAJOR.MINOR.PATCH where 1. MAJOR is bumped when there is a breaking change, 2. MINOR is bumped when a new feature is added in a backward-compatible way, 3. PATCH is bumped when a bug is fixed in a backward-compatible way.

Versions bellow 1.0.0 are considered experimental and breaking changes may occur at any time.

5. Contributing
---------------

[](#5-contributing)

Contributions are welcomed! There are many ways to contribute, and we appreciate all of them. Here are some of the major ones:

- [Bug Reports](https://github.com/NicolasGuilloux/phpunit-dependency-injection-bundle/issues): While we strive for quality software, bugs can happen, and we can’t fix issues we’re not aware of. So please report even if you’re not sure about it or just want to ask a question. If anything the issue might indicate that the documentation can still be improved!
- [Feature Request](https://github.com/NicolasGuilloux/phpunit-dependency-injection-bundle/issues): You have a use case not covered by the current api? Want to suggest a change or add something? We’d be glad to read about it and start a discussion to try to find the best possible solution.
- [Pull Request](https://github.com/NicolasGuilloux/phpunit-dependency-injection-bundle/pulls): Want to contribute code or documentation? We’d love that! If you need help to get started, GitHub as [documentation](https://help.github.com/articles/about-pull-requests/) on pull requests. We use the ["fork and pull model"](https://help.github.com/articles/about-collaborative-development-models/) were contributors push changes to their personal fork and then create pull requests to the main repository. Please make your pull requests against the `master` branch.

As a reminder, all contributors are expected to follow our [Code of Conduct](./CODE_OF_CONDUCT.md).

6. License
----------

[](#6-license)

phpunit-dependency-injection-bundle is distributed under the terms of the MIT license.

See [LICENSE](./LICENSE) for details.

7. Hacking
----------

[](#7-hacking)

You might use Docker and `docker-compose` to hack the project. Check out the following commands.

```
# Start the project
docker-compose up -d

# Install dependencies
docker-compose exec application composer install

# Run tests
docker-compose exec application bin/phpunit

# Run a bash within the container
docker-compose exec application bash
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Total

4

Last Release

1435d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.3

v1.1.0.x-devPHP ^8.0 || ^7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/f0919e3bb14bfe0498415965af2207ceb2bbcebd5ba9da233ef675115b253e8b?d=identicon)[Nover](/maintainers/Nover)

---

Top Contributors

[![NicolasGuilloux](https://avatars.githubusercontent.com/u/4090627?v=4)](https://github.com/NicolasGuilloux "NicolasGuilloux (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nicolasguilloux-phpunit-dependency-injection-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/nicolasguilloux-phpunit-dependency-injection-bundle/health.svg)](https://phpackages.com/packages/nicolasguilloux-phpunit-dependency-injection-bundle)
```

###  Alternatives

[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k172.9M1.8k](/packages/symfony-security-bundle)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[acquia/orca

A tool for testing a company's software packages together in the context of a realistic, functioning, best practices Drupal build

32902.4k](/packages/acquia-orca)

PHPackages © 2026

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