php 有没有办法在不安装服务器的情况下在本地测试PHP?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21495733/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there any way to test PHP locally without installing a server?
提问by Supuhstar
I'm looking for something like http://phpfiddle.org/, but completely local. I don't want to commit to installing something as complex as Apache, then PHP on top of that, just to try out code when I'm offline. Is there anything that can run PHP 5.5 on the local machine without installing an entire server underneath it?
我正在寻找类似http://phpfiddle.org/ 的东西,但完全是本地的。我不想承诺安装像 Apache 这样复杂的东西,然后是 PHP,只是为了在我离线时尝试代码。有什么可以在本地机器上运行 PHP 5.5 而无需在其下安装整个服务器的东西吗?
回答by Eugen Dimboiu
There's no need for a server if using PHP 5.5+ - it has a built-in server (http://www.php.net/manual/en/features.commandline.webserver.php)
如果使用 PHP 5.5+,则不需要服务器 - 它有一个内置服务器(http://www.php.net/manual/en/features.commandline.webserver.php)
Just use:
只需使用:
$ cd ~/public_html
$ php -S localhost:8000
回答by Attila Fulop
As a minimalistic solution, on the command line you can also start php in interactive shell with php -athat will execute the commands you enter line by line. I often use it for testing small snippets of code.
作为一种简约的解决方案,在命令行上,您还可以在交互式 shell 中启动 php php -a,它将逐行执行您输入的命令。我经常用它来测试小代码片段。
回答by Uchiha Itachi
You can download a portable webserver http://www.usbwebserver.net/en/and use this script under it https://github.com/websiteduck/Run-PHP-Code
你可以下载一个便携式网络服务器http://www.usbwebserver.net/en/并在它下面使用这个脚本https://github.com/websiteduck/Run-PHP-Code
回答by Attila Fulop
回答by Lucky
For Windows Users:
对于 Windows 用户:
Check out the ezPHP GitHub project. Per the project description...
查看 ezPHP GitHub 项目。根据项目描述...
EzPHP is an alternative to Xamp/Wamp. EzPHP is the easiest way to setup a PHP development environment for learning PHP programming on Windows.
The scope of this project is to provide a single .exe file that will get you a PHP developing server.
EzPHP 是 Xamp/Wamp 的替代品。EzPHP 是设置 PHP 开发环境以在 Windows 上学习 PHP 编程的最简单方法。
这个项目的范围是提供一个单一的 .exe 文件,它可以让你成为一个 PHP 开发服务器。
Link - https://github.com/marcomilon/ezphp
链接 - https://github.com/marcomilon/ezphp
Setting it up was simple. Download the exphp.exe file and drop it in a folder. When you run the exe, it will launch the server and generate a public_html folder and index.php file. Follow the instructions in the command window and navigate to http://localhost:8080. Now you can start developing in the public_html folder and refresh your browser to see your changes.
设置它很简单。下载 exphp.exe 文件并将其放入一个文件夹中。当您运行 exe 时,它将启动服务器并生成一个 public_html 文件夹和 index.php 文件。按照命令窗口中的说明操作并导航到http://localhost:8080。现在您可以在 public_html 文件夹中开始开发并刷新您的浏览器以查看您的更改。
回答by Attila Fulop
回答by Jentel
I really dont think so. but it isnt so complex as you think.
我真的不这么认为。但它并不像你想象的那么复杂。
if you are on windows - just download: http://www.wampserver.com/- it will install the whole server for you (mysql&phpmyadmin,php5).
如果您使用的是 Windows - 只需下载:http: //www.wampserver.com/- 它将为您安装整个服务器(mysql&phpmyadmin,php5)。
on linux - got to google: install lamp to [your-linux] -- and follow the simple instructions
在 linux 上 - 去谷歌:将灯安装到 [your-linux] - 并按照简单的说明进行操作
回答by vlad1918
You can install either XAMPP or WAMP server locally if you find it complicated to configure PHP for Apache.
如果您发现为 Apache 配置 PHP 很复杂,您可以在本地安装 XAMPP 或 WAMP 服务器。
回答by omrakhur
If you use a development environment, like Aptana Studio, you might as well click on the Run As, and run it in your preferred browser. You need WAMP/XAMPP to be installed and running in order to do so.
如果您使用开发环境,例如 Aptana Studio,您不妨单击 Run As,然后在您喜欢的浏览器中运行它。为此,您需要安装并运行 WAMP/XAMPP。

