Is there any way to test PHP locally without installing a server?

夙愿已清 提交于 2019-11-29 21:22:54
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)

Just use:

$ cd ~/public_html
$ php -S localhost:8000
Attila Fulop

As a minimalistic solution, on the command line you can also start php in interactive shell with php -a that will execute the commands you enter line by line. I often use it for testing small snippets of code.

You can download a portable webserver http://www.usbwebserver.net/en/ and use this script under it https://github.com/websiteduck/Run-PHP-Code

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

on linux - got to google: install lamp to [your-linux] -- and follow the simple instructions

You can install either XAMPP or WAMP server locally if you find it complicated to configure PHP for Apache.

You should try phpsh as well. It is a php interactive shell from the facebook developer folks with history, tab completion and quick access to documentation.

The project is maintained on github.

Use psysh which is a wonderful tool for the purpose you described.

If your project is on Laravel, then it's "built in", as tinker, so you can invoke it as php artisan tinker.

For Windows Users:

Check out the ezPHP GitHub project. Per the project description...

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.

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

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!