Last active
December 16, 2015 23:34
-
-
Save alihammad-gist/75eb28fe3fdf61789898 to your computer and use it in GitHub Desktop.
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 | |
$container['pdo'] = function ($C) {return new Pdo(..);} | |
$container['B'] = function ($c) {return new B($c['pdo']);} // pass in the dependency | |
$container['C'] = function ($c) {return new C($c['B']);} | |
class B { | |
function __construct(\PDO $a){} | |
} | |
class C { | |
function __construct(B $b){} | |
} | |
// i want to use class C | |
$c = $container['C']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment