Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

local

testbed

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?

like image 708
Ky. Avatar asked Feb 01 '14 08:02

Ky.


People also ask

Can you test PHP without a server?

You can make a PHP script to run it without any server or browser. You only need the PHP parser to use it this way. This type of usage is ideal for scripts regularly executed using cron (on *nix or Linux) or Task Scheduler (on Windows). These scripts can also be used for simple text processing tasks.

Can you test PHP offline?

In first type you can install and configure apache php and mysql one by one manually Or in second type use easy to install local server sotwares like xampp, wamp, easyPHP ect. By using any one method your pc will run as a server and you can easily test your php codes without any internet connectivity.


1 Answers

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 
like image 50
Eugen Dimboiu Avatar answered Sep 19 '22 18:09

Eugen Dimboiu