Case fixes, punctuation, spelling

This commit is contained in:
Jon 2014-09-15 22:51:39 +01:00
parent d2d7f31355
commit dcb22ac846

View file

@ -8,9 +8,9 @@ To start, create an empty directory for your project. You also need an entry poi
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. 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.
The `index.php` is the starting point, so it has to be inside the webserver directory. Which means that the webserver has access to all subdirectories. If you set things up properly, you can still prevent it from accessing your subfolders where your application files are. The `index.php` is the starting point, so it has to be inside the web server directory. This means that the web server has access to all subdirectories. If you set things up properly, you can still prevent it from accessing your subfolders where your application files are.
But sometimes things don't go according to plan. And if something goes wrong and your files are set up as explained above, your whole application source code could get exposed to visitors. I won't have to explain why this is not a good thing. But sometimes things don't go according to plan. And if something goes wrong and your files are set up as above, your whole application source code could be exposed to visitors. I won't have to explain why this is not a good thing.
So instead of doing that, create a folder in your project folder called `public`. This is a good time to create an `src` folder for your application, also in the project root folder. So instead of doing that, create a folder in your project folder called `public`. This is a good time to create an `src` folder for your application, also in the project root folder.
@ -24,7 +24,7 @@ require '../src/Bootstrap.php';
The `Bootstrap.php` will be the file that wires your application together. We will get to it shortly. The `Bootstrap.php` will be the file that wires your application together. We will get to it shortly.
The rest of the public folder is reserved for your public asset files (like javascript files and stylesheets). The rest of the public folder is reserved for your public asset files (like JavaScript files and stylesheets).
Now navigate inside your `src` folder and create a new `Bootstrap.php` file with the following content: Now navigate inside your `src` folder and create a new `Bootstrap.php` file with the following content:
@ -34,10 +34,10 @@ Now navigate inside your `src` folder and create a new `Bootstrap.php` file with
echo 'Hello World!'; echo 'Hello World!';
``` ```
Now let's see if everything is set up correctly. Open up a console and navigate into your projects `public` folder. In there type `php -S localhost:8000` and press enter. This will start the built-in webserver and you can access your page in a browser with `http://localhost:8000`. You should now see the hello world message. Now let's see if everything is set up correctly. Open up a console and navigate into your projects `public` folder. In there type `php -S localhost:8000` and press enter. This will start the built-in webserver and you can access your page in a browser with `http://localhost:8000`. You should now see the 'hello world' message.
If there is an error, go back and try to fix it. If you only see a blank page, check the console window where the server is running for errors. If there is an error, go back and try to fix it. If you only see a blank page, check the console window where the server is running for errors.
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. 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.
[next >>](2-composer.md) [next >>](2-composer.md)