From 2b12237f12809aac4722b5396a6683a48cfff4da Mon Sep 17 00:00:00 2001 From: Patrick Date: Thu, 18 Sep 2014 21:53:50 +0200 Subject: [PATCH] finished DI part --- 8-dependency-injector.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/8-dependency-injector.md b/8-dependency-injector.md index 1cfef96..110332a 100644 --- a/8-dependency-injector.md +++ b/8-dependency-injector.md @@ -68,4 +68,38 @@ $class->$method($vars); Now all your controller constructor dependencies will be automatically resolved with Auryn. -to be continued... +Go back to your `HelloWorldController.php` and change it to the following: + +```php +request = $request; + $this->response = $response; + } + + public function hello() + { + $content = '

Hello World

'; + $content .= 'Hello ' . $this->request->getParameter('name', 'stranger'); + $this->response->setContent($content); + } +} +``` + +As you can see now the class has two dependencies. Try to access the page with a GET parameter like this `http://localhost:8000/hello-world?name=Arthur%20Dent`. + +Congratulations, you have now successfully laid the groundwork for your application. + +[<< previous](7-inversion-of-control.md) \ No newline at end of file