From 38f688693321ac5a93758dcf8e87ea45297a657b Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 17 Sep 2014 22:07:26 +0200 Subject: [PATCH] added code formatting --- 1-front-controller.md | 4 ++-- 2-composer.md | 4 ++-- 3-error-handler.md | 4 ++-- 4-http.md | 10 +++++----- 5-router.md | 6 +++--- 8-dependency-injector.md | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/1-front-controller.md b/1-front-controller.md index 413924c..4062204 100644 --- a/1-front-controller.md +++ b/1-front-controller.md @@ -16,7 +16,7 @@ So instead of doing that, create a folder in your project folder called `public` Inside the `public` folder you can now create your `index.php`. Remember that you don't want to expose anything here, so put just the following code in there: -``` +```php =5.5.0", "filp/whoops": ">=1.1.2" @@ -29,7 +29,7 @@ For development that does not make sense though -- you want a nice error page. T Then after the error handler registration, throw an `Exception` to test if everything is working correctly. Your `Bootstrap.php` should now look similar to this: -``` +```php =5.5.0", "filp/whoops": ">=1.1.2", @@ -24,7 +24,7 @@ Again, edit the `composer.json` to add the new component and then run `composer Now you can add the following below your error handler code in your `Bootstrap.php` (and don't forget to remove the exception): -``` +```php $request = new \Http\HttpRequest($_GET, $_POST, $_COOKIE, $_FILES, $_SERVER); $response = new \Http\HttpResponse; ``` @@ -33,7 +33,7 @@ This sets up the `Request` and `Response` objects that you can use in your other To actually send something back, you will also need to add the following snippet at the end of your `Bootstrap.php` file: -``` +```php foreach ($response->getHeaders() as $header) { header($header); } @@ -45,14 +45,14 @@ This will send the response data to the browser. If you don't do this, nothing h Right now it is just sending an empty response back to the browser with the status code `200`; to change that, add the following code between the code snippets from above: -``` +```php $content = '

Hello World

'; $response->setContent($content); ``` If you want to try a 404 error, use the following code: -``` +```php $response->setContent('404 - Page not found'); $response->setStatusCode(404); ``` diff --git a/5-router.md b/5-router.md index f59be70..b559a51 100644 --- a/5-router.md +++ b/5-router.md @@ -14,7 +14,7 @@ By now you know how to install Composer packages, so I will leave that to you. Now add this code block to your `Bootstrap.php` file where you added the 'hello world' message in the last part. -``` +```php $dispatcher = \FastRoute\simpleDispatcher(function (\FastRoute\RouteCollector $r) { $r->addRoute('GET', '/hello-world', function () { echo 'Hello World'; @@ -48,7 +48,7 @@ This setup might work for really small applications, but once you start adding a Create a `Routes.php` file in the `src/` folder. It should look like this: -``` +```php