PHPackages                             davidecesarano/embryo-container - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. davidecesarano/embryo-container

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

davidecesarano/embryo-container
===============================

A simple and PSR-11 compatible Container.

2.0.1(5y ago)11592MITPHPPHP &gt;=7.1

Since Sep 24Pushed 5y ago2 watchersCompare

[ Source](https://github.com/davidecesarano/Embryo-Container)[ Packagist](https://packagist.org/packages/davidecesarano/embryo-container)[ Docs](https://github.com/davidecesarano/embryo-container)[ RSS](/packages/davidecesarano-embryo-container/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (3)Dependencies (2)Versions (5)Used By (2)

Embryo Container
================

[](#embryo-container)

Embryo Container is a small and PSR-11 compatible Dependency Injection Container for PHP.

Requirements
------------

[](#requirements)

- PHP &gt;= 7.1

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

[](#installation)

Using Composer:

```
$ composer require davidecesarano/embryo-container

```

Usage
-----

[](#usage)

### Create Service

[](#create-service)

Services are defined by anonymous functions that return an instance of an object:

```
$container = new \Embryo\Container\ContainerBuilder;
$container->set('connection', function(){
    return [
        'host' => 'localhost',
        'db'   => 'database',
        'user' => 'user',
        'pass' => 'pass'
    ];
});

$container->set('pdo', function($container){
    $connection = $container->get('connection');
    $mysql = 'mysql:host='.$connection['host'].';dbname='.$connection['db'], $connection['user'], $connection['pass']);
    return new \PDO($mysql);
});
```

Note that the anonymous function has access to the current container instance.

### Using Service

[](#using-service)

Using the defined services:

```
$pdo = $container->get('pdo');
```

### Automatic Injection

[](#automatic-injection)

Container can automatically create and inject dependencies with Autowiring. Autowiring is enabled by default. You can disable it using the container builder:

```
$container->useAutowiring(false);
```

Autowiring is the ability of the container to automatically create and inject dependencies. Embryo Container uses PHP's reflection to detect what parameters a constructor needs.

```
class Person
{
    public function getName()
    {
        return 'David';
    }
}

class Hello
{
    public $name;

    public function __construct(Person $person)
    {
        $this->name = $person->getName();
    }

    public function getHello()
    {
        return 'Hello '.$this->name;
    }
}

$container = new \Embryo\Container\ContainerBuilder;
$hello = $container->get('Hello');
echo $hello->getHello(); // Hello David
```

In this example, Embryo Container creates a `Person` instance (if it wasn't already created) and pass it as a constructor parameter.

### Service Provider

[](#service-provider)

Embryo Container can defines a service into a provider extending `ServiceProvider` instance:

```
use Embryo\Container\ContainerBuilder;
use Embryo\Container\ServiceProvider;

class TestServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->container->set('testService', function($container){
            $other = $container->get('otherService');
            return 'This is a Test Service! '.$other;
        });
    }
}

$container = new ContainerBuilder;
$test_service_provider = new TestServiceProvider($container);
$test_service_provider->register();
echo $container['testService']; // This is a Test Service!
```

Example
-------

[](#example)

You may quickly test this using the built-in PHP server:

```
$ cd example
$ php -S localhost:8000

```

Going to .

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

3

Last Release

2026d ago

Major Versions

1.0.0 → 2.0.02020-11-15

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16277144?v=4)[Davide Cesarano](/maintainers/davidecesarano)[@davidecesarano](https://github.com/davidecesarano)

---

Top Contributors

[![davidecesarano](https://avatars.githubusercontent.com/u/16277144?v=4)](https://github.com/davidecesarano "davidecesarano (16 commits)")

---

Tags

containerdependency-injectionphppsr-11phpcontainerPSR-11service

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/davidecesarano-embryo-container/health.svg)

```
[![Health](https://phpackages.com/badges/davidecesarano-embryo-container/health.svg)](https://phpackages.com/packages/davidecesarano-embryo-container)
```

###  Alternatives

[devanych/di-container

Simple implementation of a PSR-11 dependency injection container

124.2k3](/packages/devanych-di-container)

PHPackages © 2026

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