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:
php --server localhost:3333
or more simply:
php -S localhost:3333
That will end up spitting out something like this:
PHP 5.5.22 Development Server started at Sun May 17 11:02:26 2015 Listening on http://localhost:3333 Document root is /Users/josh/Code/joshtronic/phpave.com Press Ctrl-C to quit.
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!