Richard Holloway Blog

Built in webserver in PHP 5.4.0

Posted in March 2012 by under other

PHP 5.4.0 has just been released. You can read the announcement, which links to the new features and deprecated functionality so I wont go over it all again here.

What caught my eye though is PHP 5.4 has a built-in webserver to allow you to easily set up a test environment without having to have a local webserver already set up. I was talking about this only today with someone battling to get Concrete5 CMS set up on an old Ubuntu server in preference to running it locally due to the inconvenience of having to set up a web server on an even older install of Windows XP.

I know Ruby on Rails has WEBrick that allows you to test your code without having to set up the entire stack in advance. Well now it appears PHP has this too.

It is simple to get started too. Just run php -S localhost:8000 in the directory you want to use as the document root and visit http://localhost:8000 in your browser. Logging is output to the terminal.

Built in Webserver php 5.4.0