Phase Server - PHP Web Server

Introducing Phase Server - PHP Web Server. Phase Server is a simple and lightweight web server written in PHP which can serve up PHP web pages as well as static content (images, css, javascript, etc.).

Current Version: 0.1
Last Modified: 6th March 2011
Download: phaseserver_0.1.zip
Licence: GPL v2

Why?
Phase Server can be used to view PHP web pages in a web browser without the need for a fully functioning web server. Simply copy the single Phase Server PHP file to your hard drive and run it using the PHP command line utility (as below).

Supported Features
The web server will:

  • listen on an address and port that you optionally specify. The default is 127.0.0.1:80.
  • serve any files from a directory that you optionally specify. The default is the directory you are running the server script from.
  • serve index.php (if it exists) as the default document.
  • show any PHP errors in the command line window.
In version 0.1, only the GET method is supported. Plans for handling POST requests are underway.

Installing/Running Phase Server
  1. Download/install PHP from www.php.net.
  2. Edit the default php.ini file to uncomment the line "extension=php_sockets.dll"
  3. Run the Phase Server script using the PHP command line (examples below).
On Windows, to use the default settings, in a command prompt enter:
C:\path\to\php.exe phaseserver.php

On Windows, to specify settings, in a command prompt enter:
C:\path\to\php.exe phaseserver.php 127.0.0.1 80 C:\www

On Windows you can make this process easier by creating a command line batch file.
  1. In notepad enter: 
    C:\path\to\php.exe phaseserver.php 127.0.0.1 80 C:\www
    pause
  2. Save it as "PhaseServer.bat"
  3. Start the server by opening this file. You can also add this to your computer's start up tasks.
Future Features
These are the intended features which will be available in future versions of Phase Server:
  1. Handling of POST requests
  2. Routing of virtual paths by either specifying a PHP file or reading and parsing a .htaccess file.
  3. Session handling
If you would like to suggest any new features, please use the comments section below or the contact form.
Update (2011-08-27):
Since this post was first done, PHP 5.4.0 has a built in web server. While the above is a proof of concept, you should probably look into the built in web server here: http://php.net/manual/en/features.commandline.webserver.php