2017 © Pedro Peláez
 

library container

Simple PSR-11 Container implementation for storing object instances

image

yoshi2889/container

Simple PSR-11 Container implementation for storing object instances

  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 7 % Grown

The README.md

PSR-11 Object container

Build Status Scrutinizer Code Quality Scrutinizer Code Coverage Latest Stable Version Latest Unstable Version Total Downloads, (*1)

Simple PSR-11 Container implementation for storing object instances., (*2)

Installation

You can install this class via composer:, (*3)

composer require yoshi2889/container, (*4)

Usage

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

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., (*6)

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., (*7)

An example of proper usage:, (*8)

<?php

class ExampleClass implements \Yoshi2889\Container\ComponentInterface
{
    use \Yoshi2889\Container\ComponentTrait;

    public function test()
    {
        echo 'Hello world!';
    }
}

$componentContainer = new \Yoshi2889\Container\ComponentContainer();
$exampleClassInstance = new ExampleClass();

$componentContainer->add($exampleClassInstance);

// echoes 'Hello world!'
ExampleClass::fromContainer($componentContainer)->test();

License

This code is released under the MIT License. Please see LICENSE to read it., (*9)

The Versions

30/07 2018

dev-master

9999999-dev

Simple PSR-11 Container implementation for storing object instances

  Sources   Download

MIT

The Requires

 

The Development Requires

19/07 2017

v0.1.1

0.1.1.0

Simple PSR-11 Container implementation for storing object instances

  Sources   Download

MIT

The Requires

 

The Development Requires

28/06 2017

v0.1

0.1.0.0

Simple PSR-11 Container implementation for storing object instances

  Sources   Download

MIT

The Requires

 

The Development Requires