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...