Is there a simple PHP development server?

PhpWebserver

Php Problem Overview


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?

Php Solutions


Solution 1 - Php

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

cd ~/public_html
php -S localhost:8000

Solution 2 - Php

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.)

Solution 3 - Php

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.

Solution 4 - Php

###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"

Solution 5 - Php

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.

Solution 6 - Php

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

Solution 7 - Php

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

Solution 8 - Php

AppServ has always setup everything you need nicely!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmdashxView Question on Stackoverflow
Solution 1 - PhpHBv6View Answer on Stackoverflow
Solution 2 - PhpssokolowView Answer on Stackoverflow
Solution 3 - PhptherufaView Answer on Stackoverflow
Solution 4 - PhpNishchitView Answer on Stackoverflow
Solution 5 - PhpctcherryView Answer on Stackoverflow
Solution 6 - PhpKeeperView Answer on Stackoverflow
Solution 7 - Phpfe_lix_View Answer on Stackoverflow
Solution 8 - PhpfireView Answer on Stackoverflow