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

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


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.


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

Tags:

Php

Local

Testbed