yep/container

dev-master 2018-01-07 03:03 UTC

This package is auto-updated.

Last update: 2024-10-11 19:05:49 UTC


README

Build Status Scrutinizer Code Quality Scrutinizer Code Coverage Latest Stable Version Total Downloads License

Dsn

Packagist

Dsn is available on Packagist.org, just add the dependency to your composer.json.

{
  "require" : {
    "yep/container": "dev-master"
  }
}

Usage

<?php
use Yep\Container\ContainerInterface;
use Yep\Container\ContainerTrait;

class Container implements ContainerInterface
{
    use ContainerTrait;

    public function someServiceFactory()
    {
        return new SomeService($this->getParameter('someParameter'));
    }
}

$container = new Container(['someParameter' => 'foo']);
$someService = $container->getService('someService');

or

<?php
class Container extends Yep\Container\Container
{
    public function someServiceFactory()
    {
        return new SomeService($this->getParameter('someParameter'));
    }
}

$container = new Container(['someParameter' => 'foo']);
$someService = $container->getService('someService');