PHP Dev Environment One-Liner

Posted on Wed 17 April 2019 in php • Tagged with docker

Here's the fastest way to get your PHP app running. No MAMP, WAMP, apache or any of that nonsense.

Moreover, it allows you to run multiple projects independently.

I'm assuming you have docker.

tl;dr

This runs the php docker image, mounts the current directory, and spins up a server on port 8086

$ docker run -v $(pwd):/www -it -p8086:8086  php:5.6-alpine sh -c "cd www; php -S 0.0.0.0:8086"

The Full Version

Create your index.php

$ cat > index.php
<html><body><h1><?php print("Hello World!") ?> </h1></body></html>
CTRL-D

Run the Server

$ docker …
Continue reading