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

AbandonedArchivedLibrary

yoshi2889/container
===================

Simple PSR-11 Container implementation for storing object instances

v0.1.1(8y ago)06071[4 PRs](https://github.com/Yoshi2889/container/pulls)MITPHPPHP &gt;=7.1.0

Since Jun 28Pushed 5y ago1 watchersCompare

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

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

PSR-11 Object container
=======================

[](#psr-11-object-container)

[![Build Status](https://camo.githubusercontent.com/ecf26786f1b4a151db85294f065ac107a4c6ed11072fb277b7ca20e1113f871a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f596f736869323838392f636f6e7461696e65722f6261646765732f6275696c642e706e67)](https://scrutinizer-ci.com/g/Yoshi2889/container/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/df87ddcd79c70738819dc1742bb03daa6f876b6fe005ece8ada4cf580e9654ca/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f596f736869323838392f636f6e7461696e65722f6261646765732f7175616c6974792d73636f72652e706e67)](https://scrutinizer-ci.com/g/Yoshi2889/container/?branch=master)[![Scrutinizer Code Coverage](https://camo.githubusercontent.com/909f64fe42be0a0ca09cff40d9ab3a0fc8bc6136c71ddfc8a4719537f009d1d7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f596f736869323838392f636f6e7461696e65722f6261646765732f636f7665726167652e706e67)](https://scrutinizer-ci.com/g/Yoshi2889/container/code-structure/master/code-coverage)[![Latest Stable Version](https://camo.githubusercontent.com/85e0c9044a938211773835b00b4026fbdc7a5d993f917e516768be53f2bf546c/68747470733a2f2f706f7365722e707567782e6f72672f796f736869323838392f636f6e7461696e65722f762f737461626c65)](https://packagist.org/packages/yoshi2889/container)[![Latest Unstable Version](https://camo.githubusercontent.com/192d4d19b06548c89edfc0fd7661980ff844a6cc0b0815b29d1f8dcfc1a3146c/68747470733a2f2f706f7365722e707567782e6f72672f796f736869323838392f636f6e7461696e65722f762f756e737461626c65)](https://packagist.org/packages/yoshi2889/container)[![Total Downloads](https://camo.githubusercontent.com/cb9fc6e9610c87724b55cef1c6510368f7720be346b470484ba614b6e939538d/68747470733a2f2f706f7365722e707567782e6f72672f796f736869323838392f636f6e7461696e65722f646f776e6c6f616473)](https://packagist.org/packages/yoshi2889/container)

Simple PSR-11 Container implementation for storing object instances.

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

[](#installation)

You can install this class via `composer`:

`composer require yoshi2889/container`

Usage
-----

[](#usage)

First, instantiate a new ComponentContainer. This is the object which will keep references to the components you put in it.

For any class that may be added to the ComponentContainer, it must implement the `ComponentInterface`. Optionally, the `ComponentTrait` trait may be used to provide a ready-to-use means to implement the `ComponentInterface`.

After adding an instance to the container, it may be retrieved either by using the `get` method on the container while providing the full class name, or, more conveniently, via the static `fromContainer` method on the component.

An example of proper usage:

```
