2017 © Pedro Peláez
 

library dimple

Dirt simple dependency injection container

image

glenjamin/dimple

Dirt simple dependency injection container

  • Saturday, July 27, 2013
  • by glenjamin
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Dimple

Dirt simple dependency injection container based loosely on Pimple, (*1)

Install

composer require glenjamin/dimple

Usage

$di = new \Dimple\Dimple();

$di->setup('app', function($di) {
    return new Application($di->get('db'), $di->get('logger'));
});

$di->setup('db', function($di) {
    return new \PDO($di->get('db-string'));
});

$di->set('dbstring', 'mysql://localhost');
$di->setup('logger', function($di) {
    return new Logger($di->get('logfile', '/dev/null'));
});

$app = $di->get('app');
$app->run();

How do I return the same instance on subsequent calls?

You don't., (*2)

Is it fast?

Unfortunately not massively, although it's not too bad, (*3)

> php benchmark.php
10000000 Iterations
Raw: 4.3745291233063
Dimpled: 14.07391500473

Overhead: 221.724113%

It's a little over two times slower than raw object initialisation. If you use it for only your service level objects it should be palatable., (*4)

The Versions

27/07 2013

dev-master

9999999-dev

Dirt simple dependency injection container

  Sources   Download

MIT

The Requires

  • php >= 5.3

 

The Development Requires

by Glen Mailer

27/07 2013

v0.1.0

0.1.0.0

Dirt simple dependency injection container

  Sources   Download

MIT

The Requires

  • php >= 5.3

 

The Development Requires

by Glen Mailer