2012-07-30

Using The PHP 5.4 Webserver On Windows

Starting a server from the command line
PHP 5.4 has an built-in webserver. For local development it is not necessary to install Apache Httpd or another webserver anymore. You can just start an server from the command line.

Change the directory to your project directory. The argument -S starts the webserver. You need to specify a host and a port. All requests are shown in the console window.

A Shortcut

To make things a little easier you can create a windows shortcut. This allows you to change the console window size, font and color, too. The following pictures show the particular steps:
Step 1: Create A Shortcut
Step 2: Select the PHP binary
Step 3: Name the shortcut
Step 4: Change command and working directory
Step 5: Change the window size

2 comments:

  1. Finally PHP comes with an in built web server, this will be a nice way to test PHP code. Having one doubt regarding this, whether this will work or not as most of the PHP scripts on the web run on an Apache server.

    ReplyDelete
  2. The main problems are possible differences in Environment Variables and URL rewriting.

    The most important environment variables are here, but some little abstraction and encapsulation is always nice for this. PHP has different environment variables depending on the SAPI. Treat them as optional and implement fallbacks/defaults.

    For the second point you can use router scripts, this is a major difference, but it works as an bootstrap without changes to the actual application logic.

    ReplyDelete

x