Created
August 30, 2015 02:19
-
-
Save sword-jin/458aaeb544c7a39e785e to your computer and use it in GitHub Desktop.
Laravel IOC understand.
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
class Foo | |
{ | |
private $bar; | |
private $baz; | |
public function __construct(Bar $bar, Baz $baz) | |
{ | |
$this->bar = $bar; | |
$this->baz = $baz; | |
} | |
} | |
class Bar{} | |
class Baz{} | |
class Mock{} | |
App::instance('Foo', new Mock); | |
App::bind('Foo', function() { | |
return new Foo(new Bar, new Baz); | |
}); | |
get('foo', function() { | |
dd(App::make('Foo')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment