From 479b5d3ff838bb4882516ca4d09931099ecf4fac Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 17 Sep 2014 22:05:09 +0200 Subject: [PATCH] expanded di part --- 8-dependency-injector.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/8-dependency-injector.md b/8-dependency-injector.md index 2ee20e7..8ef7e8a 100644 --- a/8-dependency-injector.md +++ b/8-dependency-injector.md @@ -10,7 +10,7 @@ My favorite injector is [Auryn](https://github.com/rdlowrey/Auryn), so install ` Create a new file called `Dependencies.php` in your `src/` folder. In there add the following content: -``` +```php make('Http\HttpRequest'); +$response = $injector->make('Http\HttpResponse'); +``` + +The other part that has to be changed is the dispatching of the route. Before you had the following code: + +```php +$class = new $className($response); +$class->$method($vars); +``` + +Change that to the following: + +```php +$class = $injector->make($className); +$class->$method($vars); +``` + +Now all your controller constructor dependencies will be automatically resolved with Auryn. + to be continued...