April 01, 2012
PHP 5.4 supports a built-in web server which can be used for testing purpose which is good because we can test scripts quickly without having to install Apache.
1. Download and extract PHP 5.4.0 on your system. Follow this guide if you are an XAMPP user.
2. Open console ( Start -> Run -> cmd on Windows ) and navigate to PHP's current directory.
3. Now execute following command to start the build-in server:
php -S localhost:5555
Here we are telling PHP to start local server on port 5555
If everything works fine you'll see a message saying "PHP development server has started".
PHP will also output errors and warnings. ( In my case DLL for zip extension if missing )
Now lets see if our server is listening and responding to requests.
4. Create a simple index.php in Document Root. ( F:\Installs\Xampp\php\ in my case )
5. Open your favorite browser. I use Firefox.
6. Go to this URL: http://localhost:5555/index.php
7. You should see something like this.
Congratulations! The Built-in webserver is working properly and responding to requests and we can now test our script even without installing Apache on our Systems. Note that this built-in PHP server should not be used in production but only for testing.