Is there a simple PHP development server? [closed]

2019-01-30 06:13发布

问题:

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?

回答1:

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.



回答2:

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

cd ~/public_html
php -S localhost:8000


回答3:

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



回答4:

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"


回答5:

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.



回答6:

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



回答7:

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


回答8:

AppServ has always setup everything you need nicely!



标签: php webserver