yep/container

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

This package is auto-updated.

Last update: 2024-11-11 19:16:39 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');