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 = '