Skip to content

Instantly share code, notes, and snippets.

@sword-jin
Created August 30, 2015 02:19
Show Gist options
  • Save sword-jin/458aaeb544c7a39e785e to your computer and use it in GitHub Desktop.
Save sword-jin/458aaeb544c7a39e785e to your computer and use it in GitHub Desktop.
Laravel IOC understand.
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