PHPackages                             kocsismate/di-container-benchmarks - 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. kocsismate/di-container-benchmarks

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

kocsismate/di-container-benchmarks
==================================

Benchmarks of some popular PHP DI Containers

7811[1 PRs](https://github.com/kocsismate/php-di-container-benchmarks/pulls)

Since Jun 19Compare

[ Source](https://github.com/kocsismate/php-di-container-benchmarks)[ Packagist](https://packagist.org/packages/kocsismate/di-container-benchmarks)[ RSS](/packages/kocsismate-di-container-benchmarks/feed)WikiDiscussions Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

PHP DI Container Benchmarks
===========================

[](#php-di-container-benchmarks)

[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)[![Gitter](https://camo.githubusercontent.com/552fdabb5d69684cf7db180869bfed0db8827c2f57e39906ab5826362625ab03/68747470733a2f2f6261646765732e6769747465722e696d2f6b6f637369736d6174652f7068702d64692d636f6e7461696e65722d62656e63686d61726b732e737667)](https://gitter.im/kocsismate/php-di-container-benchmarks?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

Table of Contents
-----------------

[](#table-of-contents)

- [Introduction](#introduction)
- [Results](#results)
- [Install](#install)
- [Usage](#usage)
- [Contributing](#contributing)
- [Support](#support)
- [Credits](#credits)
- [License](#license)

Introduction
------------

[](#introduction)

In 2014, a really interesting benchmark about DI Containers for PHP [was published](https://www.sitepoint.com/php-dependency-injection-container-performance-benchmarks/) on Sitepoint. Unfortunately, [the implementation](https://github.com/TomBZombie/php-dependency-injection-benchmarks) of the tests turned out to be quite controversial, so the benchmark itself wasn't really insightful.

I have been interested in the topic since then so I wanted to conduct another benchmark that also tries to measure real-life performance, while being as unbiased and reliable as possible.

Results
-------

[](#results)

You can find the benchmark results [here](https://kocsismate.github.io/php-di-container-benchmarks/benchmark.html).

Install
-------

[](#install)

You can simply download or clone this repository as well as install it via [Composer](https://getcomposer.org) by running the command below:

```
$ composer require kocsismate/di-container-benchmarks:dev-master
```

Usage
-----

[](#usage)

### Usage with Docker

[](#usage-with-docker)

As a prerequisite, [Docker Compose](https://www.docker.com/products/docker-compose) and at least Docker 17.06 CE has to be installed on your machine in order to use this benchmark method.

Copy the `.env.dist` file to `.env` and feel free to override the values in it. Now, you can run

```
./benchmark.sh docker
```

to execute the measurements.

The HTML output will be generated in the "docs" directory.

### Usage on AWS EC2

[](#usage-on-aws-ec2)

As a prerequisite, [Terraform](https://www.terraform.io) and `git` has to be installed on your machine in order to use this benchmark method.

First, create the necessary config file by copying the `aws.tfvars.dist` to `aws.tfvars` in the `build/infrastructure/config/aws.tfvars.dist` directory:

```
cp build/infrastructure/config/aws.tfvars.dist build/infrastructure/config/aws.tfvars
```

Then, override the values in it:

- `access_key`: the access key of your AWS account
- `secret_key`: the secret access key of your AWS account
- `ssh_key_name`: the name of your key pair added to EC2
- `ssh_private_key`: the file name of your private key
- `region`: it is "eu-central-1" by default, but you should choose the closest one to your area
- `image_name`: the name of the EC2 image
- `image_architecture`: the CPU architecture of the EC2 image (e.g. x86\_64 or arm64)
- `instance_type`: it is "C5.large" by default (this instance type is out of the scope of the free tier!)

Finally, you have to copy your private key in the "build/infrastructure/config" directory with a file name that matches the one defined in the `ssh_private_key` setting.

Now, you are ready to go:

```
./benchmark.sh aws
```

The HTML output will be generated in the "docs" directory.

### Usage on your host machine

[](#usage-on-your-host-machine)

If the above possibilities aren't available to you then you have to take several steps before running the benchmark:

- Install a web server and configure it to be able to serve "public/index.php"
- Install PHP 8.0 at least with OPcache and preloading enabled
- Install Composer
- Set the `BENCHMARK_URL` environment variable to the URL where "public/index.php" is available. For instance:

```
export BENCHMARK_URL=http://localhost/index.php
```

Now you can simply type the following in order to run the benchmark:

```
.\benchmark.sh host
```

If you don't want to specify the benchmark URL as an environment variable then you can also pass it as an argument:

```
./benchmark.sh host http://localhost/index.php
```

### Usage from the browser

[](#usage-from-the-browser)

You can even run tests manually from your browser. When the benchmark's Docker containers are running, just visit `localhost:8090`, otherwise you have to locate the `BENCHMARK_URL` URL (mentioned in the previous section). For further information, refer to the URL in question, it provides you with detailed instructions.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Support
-------

[](#support)

Please see [SUPPORT](SUPPORT.md) for details.

Credits
-------

[](#credits)

- [Máté Kocsis](https://github.com/kocsismate)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see the [License File](LICENSE) for more information.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2276273?v=4)[Woohoo Labs.](/maintainers/woohoolabs)[@woohoolabs](https://github.com/woohoolabs)

### Embed Badge

![Health badge](/badges/kocsismate-di-container-benchmarks/health.svg)

```
[![Health](https://phpackages.com/badges/kocsismate-di-container-benchmarks/health.svg)](https://phpackages.com/packages/kocsismate-di-container-benchmarks)
```

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14228.7M341](/packages/dms-phpunit-arraysubset-asserts)[phpbenchmark/phpbenchmark

Easy to use benchmark toolkit for your PHP-application. This library contains classes for comparing algorithms as well as benchmarking application responses

8011.5k2](/packages/phpbenchmark-phpbenchmark)

PHPackages © 2026

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