I recently updated [HolidayAPI][holidayapi] to no longer use my PHP framework because I wanted the system to be easier for new developers to get up and running. Instead of including configuration files for Apache or nginx, I decided that I should just use the web server that’s baked right into PHP!
To start up PHP’s built-in web server, from the root of your project run:
or more simply:
That will end up spitting out something like this:
If you point your browser to that address you will be greeted by the PHP
server! In my case, the directory I started it in didn’t have an
(since it’s a
jekyll site ;) so I got an error. If you don’t have a project
handy, just create
index.php in the directory and you should be greeted by
This is awesome for development purposes since it means you don’t have to worry about setting up a web server and distributing conf files. As good as it is, it is not suggested for production use, as per the documentation.
Next week I’ll talk about basic page routing so we can use the built-in web
server without needing to include
.php at the end of every page!