Is there a simple PHP development server?

When writing web apps in Python, it's brain dead easy to run a development server. Django and Google App Engine (GAE) both ship with simple servers.

The main feature I'm looking for is no configuration. I want something like the GAE dev server where you just pass the directory of the app as a parameter when the server is started.

Is there a reason that this is more difficult with PHP?

45749 次浏览

When I need a quick php web server for local testing I use QuickPHP

Use XAMPP: http://www.apachefriends.org/en/xampp.html Its easy to install and config.

EDIT:
since PHP 5.4 (which was released 2 years after this answer) there's a built-in web-server. Today this is inaccurate, please use the method provided by k0pernikus in his answer.

AppServ has always setup everything you need nicely!

We have developed a very small development server which has a similar behavior as django development server.

The software is called sng and work with php and nginx. It is made in javascript and nodejs, you can install it very easily with npm :

npm install sng

If it's a feasible option on whatever platform you're using, PHP 5.4 has a Django-like development server.

You may also want the snippet I use to detect the development server and replicate the two most common uses of mod_rewrite. (Hiding index.php in URLs and passing static files through to be served)

(Yes, there is a built-in command-line switch for that, but it doesn't quite match the mod_rewrite snippet most people use and caused spurious 404 errors for me because of that mismatch.)

Actually PHP 5.4.0 recently presented its built-in web server:

cd ~/public_html
php -S localhost:8000

Update: I've developed a docker based version that I have started using instead of easy_php_dev: localdev

easy_php_dev makes multi-site php development very easy and fast. Only limitation is it is designed only for OSX. Disclosure: I'm the author.

Try using batch file

  1. Open notepad
  2. php -S localhost:8000
  3. save file as .bat extension => server.bat
  4. now click on server.bat, your server is ready on http://localhost:8000.

DEP

if you got error php not recognize any internal or external command then goto environment variable and edit path to php.exe

"C:\wamp\bin\php\php5.4.3"