From b933d835951626cd58280b74d26edfd55c295a30 Mon Sep 17 00:00:00 2001 From: Patrick Date: Sun, 14 Sep 2014 20:10:37 +0200 Subject: [PATCH] refactored --- 1-front-controller.md | 4 ++-- 2-composer.md | 6 ++++-- 3-error-handler.md | 4 +++- 6-controllers.md | 2 ++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/1-front-controller.md b/1-front-controller.md index 6f8af0f..411bb00 100644 --- a/1-front-controller.md +++ b/1-front-controller.md @@ -2,6 +2,8 @@ ### Front Controller +A [front controller](http://en.wikipedia.org/wiki/Front_Controller_pattern) is a single point of entry for your application. + To start, create an empty directory for your project. You also need an entry point where all requests will go to. This means you will have to create an `index.php` file. A common way to do this is to just put the `index.php` in the root folder of the projects. This is also how some frameworks do it. Let me explain why you should not do this. @@ -38,6 +40,4 @@ If there is an error, go back and try to fix it. If you only see a blank page, c Now would be a good time to commit your progress. If you are not already using git, set up a repository now. This is not a git tutorial so I won't go over the details. But using version control should be a habit, even if it is just for a tutorial project like this. -What you have set up now is called a [front controller](http://en.wikipedia.org/wiki/Front_Controller_pattern). All requests are going to the same file that then decides what to do with it. This is a very common software design pattern. - [next >>](2-composer.md) \ No newline at end of file diff --git a/2-composer.md b/2-composer.md index 2695755..16ad1fd 100644 --- a/2-composer.md +++ b/2-composer.md @@ -2,9 +2,11 @@ ### Composer -Just because you are not using a framework does not mean you will have to reinvent the wheel every time you want to do something. For PHP there is a dependency manager called composer that you can use to pull in 3rd party packages for your application. +[Composer](https://getcomposer.org/) is a dependency manager for PHP. -If you don't have composer installed already, head over to the [website](https://getcomposer.org/) and install it. You can find composer packages for your project on [packagist](https://packagist.org/). +Just because you are not using a framework does not mean you will have to reinvent the wheel every time you want to do something. With composer you can install 3rd party libraries for your application. + +If you don't have composer installed already, head over to the website and install it. You can find composer packages for your project on [packagist](https://packagist.org/). Create a new file in your project root folder called `composer.json`. This is the composer configuration file that will be used to configure your project and it's dependencies. It must be valid json or composer will fail. diff --git a/3-error-handler.md b/3-error-handler.md index e3a7eb3..8fcc823 100644 --- a/3-error-handler.md +++ b/3-error-handler.md @@ -2,7 +2,9 @@ ### Error Handler -The first package for the project will be an error handler that will provide you with nice errors. A nice error page with a lot of information for debugging goes a long way during development. +An error handler allows you to customize what happens if your code results in an error. + +A nice error page with a lot of information for debugging goes a long way during development. So the first package for your application will take care of that. I like [filp/whoops](https://github.com/filp/whoops), so I will show how you can install that package for your project. If you prefer another package, feel free to install that one. This is the beauty of programming without a framework, you have total control over your project. diff --git a/6-controllers.md b/6-controllers.md index 33a6eb3..e028b68 100644 --- a/6-controllers.md +++ b/6-controllers.md @@ -2,4 +2,6 @@ ### Controllers +A quick definition before we start. 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 anyways, 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). + to be continued... \ No newline at end of file