diff --git a/5-router.md b/5-router.md index 764d318..2bb5c59 100644 --- a/5-router.md +++ b/5-router.md @@ -1,4 +1,4 @@ -[<< previous](4-http.md) | [next >>](6-controllers.md) +[<< previous](4-http.md) | [next >>](6-dispatching-to-a-class.md) ### Router @@ -76,4 +76,4 @@ $dispatcher = \FastRoute\simpleDispatcher($routeDefinitionCallback); This is already an improvement, but now all the handler code is in the `Routers.php` file. This is not optimal, so let's fix that in the next part. -[<< previous](4-http.md) | [next >>](6-controllers.md) +[<< previous](4-http.md) | [next >>](6-dispatching-to-a-class.md) diff --git a/6-controllers.md b/6-controllers.md deleted file mode 100644 index 99a41a1..0000000 --- a/6-controllers.md +++ /dev/null @@ -1,55 +0,0 @@ -[<< previous](5-router.md) | [next >>](7-inversion-of-control.md) - -### Controllers - -When I talk about a controller in this tutorial then I am just referring to a class that has handler methods. I am not talking about [MVC (Model-View-Controller)](http://martinfowler.com/eaaCatalog/modelViewController.html) controllers. MVC can't be implemented properly in PHP anyway, at least not in the way it was originally conceived. So forget about MVC and instead let's worry about [separation of concerns](http://en.wikipedia.org/wiki/Separation_of_concerns). - -Create a new folder inside the `src/` folder with the name `HelloWorld`. This will be where all your hello world related code will end up in. In there, create `HelloWorldController.php`. - -```php -$method($vars); - break; -``` - -So instead of just calling a handler method you are now instantiating the controller object and then calling the method on it. - -Now if you visit `http://localhost:8000/hello-world` everything should work. If not, go back and debug. And of course don't forget to commit your changes. - -[<< previous](5-router.md) | [next >>](7-inversion-of-control.md) \ No newline at end of file diff --git a/7-inversion-of-control.md b/7-inversion-of-control.md index 2454758..7f255e7 100644 --- a/7-inversion-of-control.md +++ b/7-inversion-of-control.md @@ -1,4 +1,4 @@ -[<< previous](6-controllers.md) | [next >>](8-dependency-injector.md) +[<< previous](6-dispatching-to-a-class.md) | [next >>](8-dependency-injector.md) ### Inversion of Control @@ -48,4 +48,4 @@ The `Http\HttpResponse` object implements the `Http\Response` interface, so it f Now everything should work again. But if you follow this example, all your controllers will have the same objects injected. This is of course not good, so let's fix that in the next part. -[<< previous](6-controllers.md) | [next >>](8-dependency-injector.md) \ No newline at end of file +[<< previous](6-dispatching-to-a-class.md) | [next >>](8-dependency-injector.md) \ No newline at end of file diff --git a/README.md b/README.md index d805359..d921ed6 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,6 @@ So let's get started right away with the [first part](1-front-controller.md). 3. [Error Handler](3-error-handler.md) 4. [HTTP](4-http.md) 5. [Router](5-router.md) -6. [Controllers](6-controllers.md) +6. [Dispatching to a Class](6-dispatching-to-a-class.md) 7. [Inversion of Control](7-inversion-of-control.md) 8. [Dependency Injector](8-dependency-injector.md)