PHPackages                             artoodetoo/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. artoodetoo/container

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

artoodetoo/container
====================

Yet another service container

v0.1.3(9y ago)1341MITPHPPHP &gt;=5.6

Since Apr 1Pushed 9y ago1 watchersCompare

[ Source](https://github.com/artoodetoo/container)[ Packagist](https://packagist.org/packages/artoodetoo/container)[ RSS](/packages/artoodetoo-container/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (5)Used By (0)

Container
=========

[](#container)

Yet another service container

Container **DOES NOT** use reflection and type hint information in any form.

Features
--------

[](#features)

Container keep two kind of values: services and parameters.

Service will instantiated when you call call it by name. *Usually* service is object type, but not nesessary. Mind it as "product" of some routine.

Methods: `get()` and `set()`.

Parameters are not instantiating, they just stored and retrieved.

Methods: `getParameter()` and `setParameter()`.

Install
-------

[](#install)

To install with composer:

```
composer require artoodetoo/container
```

Basic Usage
-----------

[](#basic-usage)

### Configuration

[](#configuration)

There are special configuraton sections:

- root used to store basic values, which can be substituted into service definition.
- `shared` node defines shared services. after it created once it can be retrieved many times.
- `multiple` node defines new instance created on every get() call

In other sections you can store any kind of information and retrieve it in dot notation (see below).

### Simple service definition

[](#simple-service-definition)

```
use R2\DependencyInjection\Container;

$config = [
  'shared' => [
    'view' => R2\Templating\Dirk::class
  ]
];
$c = new Container($config);
$c->get('view')->render('index');
```

### Parameters substitution

[](#parameters-substitution)

```
$config = [
  'ROOT'   => '\var\www\mysite',
  'PUBLIC' => '\var\www\mysite\public',
  'shared' => [
    'view' => [
      'class' => R2\Templating\Dirk::class,
      'options' => [
          'views' => '%ROOT%/views',
          'cache' => '%ROOT%/cache',
      ],
      ...
  ]
];
...
$c->get('view')->render('index');
```

### Factory method

[](#factory-method)

```
$config = [
  'shared' => [
    'userManager' => App\UserManager::class,
    'user' => '@userManager:getCurrentUser',
    ...
  ]
]
...
echo $c->get('user')->username;
```

### Container injection

[](#container-injection)

There are two ways to inject container into service instance:

1. Add interface `R2\DependencyInjection\ContainerAwareInterface` to service class and define setContainer() method.
2. Substitute container in constructor parameters. It is special name `CONTAINER`:

```
$config = [
  'shared' => [
    'example' => [
        'class' => Example::class,
        'container' => '%CONTAINER%',
    ],
  ]
];
```

### Parameters and dot notation:

[](#parameters-and-dot-notation)

```
$config = [
  'options' => [
    'cookie' => [
      'name' => 'the-cookie',
      'domain' => '.example.com'
    ]
];
...
setcookie(
  $c->getParameter('options.cookie.name'),
  $value,
  0,
  '/',
  $c->getParameter('options.cookie.domain')
);
```

### Notes and Limits

[](#notes-and-limits)

Any part of configuration can be read by getParameter, including special sections `shared` and `multiple`.

As for now, substitution patterns work in service production only.

Only parameters from config root can be used in substitution patterns.

### License

[](#license)

The Container is open-source software, licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

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

Total

4

Last Release

3395d ago

### Community

Maintainers

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

---

Top Contributors

[![artoodetoo](https://avatars.githubusercontent.com/u/577710?v=4)](https://github.com/artoodetoo "artoodetoo (14 commits)")

---

Tags

containerservice

### Embed Badge

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

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

###  Alternatives

[psr/container

Common Container Interface (PHP FIG PSR-11)

10.0k1.0B3.7k](/packages/psr-container)[league/container

A fast and intuitive dependency injection container.

86387.8M343](/packages/league-container)[php-di/php-di

The dependency injection container for humans

2.8k48.9M994](/packages/php-di-php-di)

PHPackages © 2026

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