Created
July 4, 2013 12:48
-
-
Save rafi/5927424 to your computer and use it in GitHub Desktop.
Pimple DI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Test { | |
public $init = FALSE; | |
public function __construct() { | |
echo "Initialized Test"; | |
$this->init = TRUE; | |
} | |
} | |
$di = new Pimple; | |
$di['a'] = new Test; | |
$di['b'] = function () { return new Test; }; | |
$di['c'] = $di->share( | |
function () { return new Test; }; | |
}); | |
var_dump($di['a']); | |
var_dump($di['a']); | |
var_dump($di['b']); | |
var_dump($di['b']); | |
var_dump($di['c']); | |
var_dump($di['c']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment