2017 © Pedro Peláez
 

library container

image

fratily/container

  • Thursday, June 28, 2018
  • by kento-oka
  • Repository
  • 0 Watchers
  • 0 Stars
  • 41 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 21 Versions
  • 71 % Grown

The README.md

FratilyPHP Container

This is simple Dependency Injection Container., (*1)

Install

$ composer require fratily/container

Usage

use Fratily/Container/Builder/AbstractProvider;
use Fratily/Container/Builder/ContainerBuilder;
use Fratily/Container/ContainerFactory;

class Foo
{
    public function __construct(
        LoggerInterface $logger,
        SplQueue $queue,
        string $prefix
    ) {/* ... */}

    public function setCache(CacheInterface $cache): void {/* ... */}

    public function lock(): void {/* ... */}    
}

class SampleProvider extends AbstractProvider
{
    public function build(ContainerBuilder $builder): void
    {
        $builder->injection(Foo::class)
            ->addArgument("queue", new LazyNew(SplQueue::class))
            ->addArgument(3, new LazyGetParameter("parameter.prefix"))
            ->addSetter("setCache", new LazyGet(CacheInterface::class))
        ;

        $builder->parameter("parameter.prefix")
            ->setValue("this.is.prefix")
        ;

        $builder->service("service.foo")
            ->setValueByClass(Foo::class)
        ;

        $builder->service(LoggerInterface::class)
            ->setValueByFactory(
                function () {
                    return new Logger();
                }
            )
        ;

        $builder->service(CacheInterface::class)
            ->setValueByFactory(
                function () {
                    return new Cache();
                }
            )
        ;
    }

    public function modify(Container $container): void
    {
        $container->get("service.foo")->lock();
    }
}

$factory = new ContainerFactory();

$factory->add(new SampleProvider());

$container = $factory->create();

$foo = $container->get("service.foo");

The Versions

28/06 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

28/06 2018

v0.3.5

0.3.5.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

11/06 2018

v0.3.4

0.3.4.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

10/06 2018

v0.3.3

0.3.3.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

09/06 2018

v0.3.2

0.3.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

08/06 2018

v0.3.1

0.3.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

08/06 2018

v0.3.0

0.3.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

05/06 2018

v0.2.5

0.2.5.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

24/05 2018

v0.2.4

0.2.4.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

23/05 2018

v0.2.3

0.2.3.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

23/05 2018

v0.2.2

0.2.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

22/05 2018

v0.2.1

0.2.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

22/05 2018

v0.2.0

0.2.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

21/05 2018

v0.1.3

0.1.3.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

21/05 2018

v0.1.2

0.1.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

08/05 2018

v0.1.1

0.1.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

06/05 2018

v0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

04/05 2018

v0.0.4

0.0.4.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

03/05 2018

v0.0.3

0.0.3.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

03/05 2018

v0.0.2

0.0.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily

02/05 2018

v0.0.1

0.0.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kento Oka

container psr-11 fratily