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

PhpLocalTestbed

Php Problem Overview


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?

Php Solutions


Solution 1 - Php

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

Solution 2 - Php

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.

Solution 3 - Php

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

Solution 4 - Php

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.

Solution 5 - Php

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

Solution 6 - Php

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

Solution 7 - Php

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.

Solution 8 - Php

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.

Solution 9 - Php

This is what I do for simple pages:

  • Download php in zip and extract (PHP 8.0.2 ~25MB)

  • Then run

    > php.exe path\to\your\index.php>path\to\the\output\index.html
    
  • Open the result index.html with your favorite browser

You have to find a workaround for your _GETs though.

Solution 10 - Php

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.

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
QuestionKy.View Question on Stackoverflow
Solution 1 - PhpEugen DimboiuView Answer on Stackoverflow
Solution 2 - PhpAttila FulopView Answer on Stackoverflow
Solution 3 - PhpUchiha ItachiView Answer on Stackoverflow
Solution 4 - PhpAttila FulopView Answer on Stackoverflow
Solution 5 - PhpJentelView Answer on Stackoverflow
Solution 6 - Phpvlad1918View Answer on Stackoverflow
Solution 7 - PhpAttila FulopView Answer on Stackoverflow
Solution 8 - PhpLuckyView Answer on Stackoverflow
Solution 9 - PhpPonirosView Answer on Stackoverflow
Solution 10 - PhpomrakhurView Answer on Stackoverflow