2017 © Pedro Peláez
 

library almari

Almari is a micro IoC framework which implement service locator and facade pattern

image

tonjoo/almari

Almari is a micro IoC framework which implement service locator and facade pattern

  • Saturday, June 6, 2015
  • by todiadiyatmo
  • Repository
  • 1 Watchers
  • 1 Stars
  • 93 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Almari

Almari is a micro IoC framework which implement service locator and facade pattern, (*1)

Installation

You can use composer to install Almari, (*2)

composer require lotus/almari

Or you can put it on composer.json, (*3)

"require": {
        "tonjoo/almari": "*"
    }

Basic Usage

The main container class is Lotus\Almari\Container, (*4)

Adding service

use Lotus\Almari\Container as Container

$app = new Container();

// Create service, return new Foo instance
$app->bind('foo',function(){

    return new Foo();

});

Retrieve Service

$newFoo = $app->make('foo');

$newFoo2 = $app->make('foo');

Share singleton to container

use Lotus\Almari\Container as Container

$app = new Container();

$foo = new Foo();

// Share an instance
$app->share('fooSingeleton',$foo);

// Share an instance (lazy load)
$app->shareDeferred('fooSingeleton',function(){

    return new Foo();

});

// Share instance using array access
$app['fooSingeleton'] = $foo;

Retrieve instance

$myFoo = app->get('foo',$defaultValue);

// Or using array access
$myFoo = app['foo'];

Facade ability

Full example here : https://github.com/tonjoo/almari-boilerplate, (*5)

// Facading $foo to FooFacade
$aliasMapper = AliasMapper::getInstance();

$alias['FooFacade'] = 'MyProject\MyPackage\Facade\FooFacade';

$aliasMapper->facadeClassAlias($alias);

//Register container to facade
MyFacade::setFacadeContainer($app);

FooFacade::greet("Todi");

The Versions

06/06 2015

dev-master

9999999-dev http://tonjoo.com

Almari is a micro IoC framework which implement service locator and facade pattern

  Sources   Download

MIT

framework ioc facade lotus

06/06 2015

0.1.0

0.1.0.0 http://tonjoo.com

Almari is a micro IoC framework which implement service locator and facade pattern

  Sources   Download

MIT

framework ioc facade lotus