When it comes to setting up your PHP dev environment, you know the drill. Google for a LAMP/WAMP tutorial and then run through the installation steps: apache, php, mysql. Then, after setting up/checking out your project’s source code, you have to configure an apache vhost file. Well the day is getting close when we can cross the apache step off the list. I recently came across Built-in web server and took it for a test drive.
h4. Install
According to the built-in web server documentation, the built-in web server is part of PHP 5.4 which is not yet stable. We can still download, build, and try it out though. On Ubuntu with an existing PHP install, the alpha version can be built and used along side Ubuntu’s php package.
At this point, I’m not concerned about the various php configure options. You can test the build php binary:
Test out an application
Let’s try the quickstart app from Zend Framework. I’ll assume you have Zend Framework and Zend Tool already installed.
Now open your browser to http://localhost:8000.
If you see the entry page to your application, it is working.
Final Steps
Something is still missing. We need to be able to serve up static files. If using apache, this is usually accomplished by using a .htaccess file. Ralph Shindler discusses some routing options here. We can tweak Ralph’s suggestion a bit. First, create a .routing.php file in the public directory and place the following code inside:
Now, restart the web server:
Wrap Up
Keep in mind, the built-in web server is for development only. It is not something you should consider using for production. I am a bit disappointed that the routing isn’t simply part of the built-in web server. However, I look forward to the release of 5.4.