2017 © Pedro Peláez
 

library yac

Yet another container

image

asm89/yac

Yet another container

  • Thursday, November 14, 2013
  • by asm89
  • Repository
  • 4 Watchers
  • 12 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

yac

Just remembered this gem from @crell at #tnphp: "Invent yet another container? You could call YAC, and shave it!" - igorwesome, (*1)

Yet another container is yet another di container for PHP, inspired by Pimple and LazyMap. Basically blending the two together. When using it the LazyMap way it's very performant., (*2)

Defining parameters

$c = new Yac\Yac();
$c['env'] = 'dev';

Defining services

$c['session'] = function($c) { return new Session($c->env); };

Accessing parameters and services

$std = $c['std']; // pimple compatible
$std = $c->std;   // "fast" LazyMap way

Performance

Yac is much faster than Pimple!, (*3)

 $ php -n ./vendor/bin/athletic -p ./tests/YacPerformance/ -b ./tests/bootstrap.php -f GroupedFormatter
YacPerformance\YacPerformanceEvent
  fetch_service-performance
    Method Name                                 Iterations    Average Time      Ops/s    Relative
    ------------------------------  ----------  ------------ --------------   ---------  ---------
    pimpleFetchService            : [Baseline] [100,000   ] [0.0000042015409] [238,007.91486]
    yacFetchServicePimpleStyle    :            [100,000   ] [0.0000032225394] [310,314.27956] [76.70%]
    yacFetchServiceLazyMapStyle   :            [100,000   ] [0.0000027879906] [358,681.27057] [66.36%]

  fetch_initialized_service-performance
    Method Name                                 Iterations    Average Time      Ops/s    Relative
    ------------------------------  ----------  ------------ --------------   ---------  ---------
    pimpleFetchInitializedService : [Baseline] [100,000   ] [0.0000010025978] [997,408.92228]
    yacFetchInitializedServicePimpleStyle:            [100,000   ] [0.0000007377648] [1,355,445.46456] [73.59%]
    yacFetchInitializedServiceLazyMapStyle:            [100,000 ] [0.0000002871366] [3,482,663.50475] [28.64%]

Known limitations

  • No parameter/service called __yac
  • All services are "shared", "prototype" services are not yet supported
  • ...

The Versions

14/11 2013

dev-master

9999999-dev https://github.com/asm89/yac

Yet another container

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

dependency injection container service location