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

ActiveLibrary

strident/container
==================

Dependency injection container component designed for ease of use and speed. Built for Trident. Heavily inspired by Pimple.

2.0.0(11y ago)016MITPHPPHP &gt;=5.4

Since Feb 16Pushed 11y ago1 watchersCompare

[ Source](https://github.com/strident/Container)[ Packagist](https://packagist.org/packages/strident/container)[ Docs](https://github.com/Strident/Container)[ RSS](/packages/strident-container/feed)WikiDiscussions master Synced 1mo ago

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

\#Container [![Build Status](https://camo.githubusercontent.com/4cc96c145e9be9bfc0f61659d052fe99da1463065953941f7cd5a0a6b889c2bf/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f5374726964656e742f436f6e7461696e65722e737667)](https://travis-ci.org/Strident/Container)[![Coverage](https://camo.githubusercontent.com/2a9ce6789ac80c34da93219cae8a0422db9f0a90d97927c1897610b1ee08eed6/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f636f7665726167652f6769746875622f5374726964656e742f436f6e7461696e65722e737667)](https://codeclimate.com/github/Strident/Container)[![Code Climate](https://camo.githubusercontent.com/6859b8df0b56143a4e2fa9163e0ddd864c7ef7a0ebd0a6f61d91a4ab175a8c01/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6769746875622f5374726964656e742f436f6e7461696e65722e737667)](https://codeclimate.com/github/Strident/Container)

Dependency injection container component designed for ease of use and speed. Built for Trident. Heavily inspired by [Pimple](https://github.com/silexphp/Pimple).

\##Installation

Installation is available via Composer. Add the package to your composer.json:

```
$ composer require strident/container ~2.0

```

\##Usage

The container is incredibly simple to instantiate. Simply do the following:

```
use Strident\Container\Container;

$container = new Container();
```

\###Defining Services

From there, you can define services like so:

```
// 'Service' class defined somewhere, and 'dependency_name' service defined

$container->set("service_name", function($container) {
    return new Service($container->get("dependency_name"));
});
```

The services are lazy loaded (i.e. nothing is instantiated until it is called).

\###Extending a Service After Definition

You may also extend services once they have been defined (for example, if you wish to augment a service, alter settings, swap out dependencies etc). But note that once a service is used, it becomes locked and cannot be modified further.

```
$container->extend("service_name", function($service, $container) {
    $service->doSomething();
    $service->addSomething($container->get("dependency_name"));

    return $service;
});
```

\###Defining Factory Services

If you wish to return a new instance of your service every time instead of the same instance, you may define a factory service like so:

```
$container->set("service_name", $container->factory(function($container) {
    return new Service($container->get("dependency_name"));
}));
```

\###Parameters

Parameters are get / set by accessing the container like an array:

```
// Set
$container["foo"] = "A parameter can be anything";

// Get
$foo = $container["foo"];
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Total

2

Last Release

4105d ago

Major Versions

1.0.0 → 2.0.02015-02-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/78b157e833b14bfc790633c9f715d1c433cefbaff4987199a33d6319ceb5a28e?d=identicon)[Seer](/maintainers/Seer)

---

Top Contributors

[![seeruk](https://avatars.githubusercontent.com/u/2083033?v=4)](https://github.com/seeruk "seeruk (7 commits)")

---

Tags

diccomponenttridentstrident

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[lorisleiva/laravel-actions

Laravel components that take care of one specific task

2.8k7.5M115](/packages/lorisleiva-laravel-actions)[nette/di

💎 Nette Dependency Injection Container: Flexible, compiled and full-featured DIC with perfectly usable autowiring and support for all new PHP features.

92340.6M1.4k](/packages/nette-di)[laminas/laminas-servicemanager

Factory-Driven Dependency Injection Container

15955.1M694](/packages/laminas-laminas-servicemanager)[phpoffice/common

PHPOffice Common

23512.3M36](/packages/phpoffice-common)[kartik-v/yii2-mpdf

A Yii2 wrapper component for the mPDF library which generates PDF files from UTF-8 encoded HTML.

1605.5M84](/packages/kartik-v-yii2-mpdf)[contributte/application

Extra contrib to nette/application

352.8M7](/packages/contributte-application)

PHPackages © 2026

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