PHPackages                             osflab/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. osflab/container

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

osflab/container
================

OSF dynamic object container mechanism

3.0.0(8y ago)02413AGPL-3.0-or-laterPHPPHP ^7.1.0

Since Feb 26Pushed 8y ago1 watchersCompare

[ Source](https://github.com/osflab/container)[ Packagist](https://packagist.org/packages/osflab/container)[ Docs](https://github.com/osflab/container)[ RSS](/packages/osflab-container/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (3)Used By (13)

OSF Container: dynamic object management mecanism
=================================================

[](#osf-container-dynamic-object-management-mecanism)

OSF Container manages instances of your classes in order to optimize performance and accessibility. Define the instantiation policy of each class and let OSF Container create and manage your objects.

Features
--------

[](#features)

- Lazy classes instanciations
- Optimized management of the instantiation policy
- Dependency management
- Mock objects generation &amp; advanced mocking policy
- Extremely simplified access to objects

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

[](#installation)

You need at least php 7.1 and `composer`:

```
sudo apt install composer
```

### In your application via composer

[](#in-your-application-via-composer)

This is the recommended way to use this feature in a non-osf project.

Just add `osflab/container` in your composer.json file.

### From github

[](#from-github)

To test the component or participate in its development.

```
git clone https://github.com/osflab/container.git
cd container && composer update
```

Unit tests launch:

```
vendor/bin/runtests
```

Usage
-----

[](#usage)

For example, to use `Osf\Cache` component (anyware in your code):

```
$cache = \Osf\Container\OsfContainer::getCache();
```

To create your own container:

```
use Osf\Container\AbstractContainer;

class MyContainer extends AbstractContainer
{
    /**
     * Build and get on-demand \My\Class instance(s)
     * @return \My\Class
     */
    public static function getMyClass(): \My\Class
    {
        return self::buildObject('\My\Class');
    }
}
```

The `AbstractContainer::buildObject()` method takes 3 args:

- The class name
- An array of class constructor values
- A namespace string

See `OsfContainer`, `ZendContainer` and `VendorContainer` for more examples.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community16

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

Total

2

Last Release

2946d ago

PHP version history (2 changes)3.0.0PHP ^7.1.0

3.0.x-devPHP ^7.1.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/abc3dea1dc84c5b66d10072481ff94a25c852239e3597fde32e86204b636f911?d=identicon)[Guillaume Ponçon](/maintainers/Guillaume%20Pon%C3%A7on)

---

Top Contributors

[![gponcon](https://avatars.githubusercontent.com/u/1412541?v=4)](https://github.com/gponcon "gponcon (30 commits)")

### Embed Badge

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

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

PHPackages © 2026

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