PHP Dev Environment One-Liner
Tony Metzidis

Tony Metzidis @tonymet

About: Developer and Engineering Manager. Mostly backend & cloud platforms. Currently node.js & golang. Also AWS CSA Associate

Location:
SF Bay Area
Joined:
Feb 9, 2019

PHP Dev Environment One-Liner

Publish Date: Apr 17 '19
10 2

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 run -v $(pwd):/www -it -p8086:8086  php:5.6-alpine sh -c "cd www; php -S 0.0.0.0:8086"

Test Your Server

$ curl localhost:8086
<html><body><h1>Hello World! </h1></body></html>

Comments 2 total

  • Tony Metzidis
    Tony MetzidisApr 22, 2019

    I hear you. This one liner fills a use case where you need to quickly work on a PHP project for a short period of time, with minimal effort. Another idea would be to quickly prototype or test PHP concepts for beginners while avoiding the investment in tools.

    Every tool has a niche.

Add comment