One of my most used and appreciated features of PHP is its build-in webserver. I am heavily relying on it.
php -S localhost:8888
Since I try to aply docker to emulate a dev environment, I tried to figure out what the most easiest and lightweight way is to do the same with a docker container. Therefore I choose to use a precompiled php-alpine image from the official (docker hub php page).
My first working result was the following command that has to be executed in the folder where the code is:
docker run -dit --rm -v $(pwd):/home/www-data -p 8080:8080 --name simple-php-dev php:7-alpine "/bin/sh" -c "cd /home/www-data && php -S 0.0.0.0:8080 -t public && tail -f /dev/null"
With this now it is possible to see the output in the browser at localhost:8080
Don’t ask me about /dev/null
. I googled it and without it, it doesn’t work. Welcome to the world of IT :-)