M0UNTAIN 0F C0DE

Some Love For PHPs Dev Server

PHP

php -S localhost:8008

Simple, easy to remember, always within reach ❤️

PHPs built-in dev server is great, is it going to compare against the likes of Apache and nginx? No, nor should it. It's not meant to be a production server, it's the simplest little server which is quick and easy. I use it for all kinds of little projects, hacks, test servers, etc.

One thing that many people don't know is that since PHP 7.4 it supports multiple threads via an environment variable. Setting the environment variable PHP_CLI_SERVER_WORKERS=$(nproc) will automatically create as many workers as your machine has threads. This can speed up apps which make a lot of parallel requests.

I have set this env variable in my .bashrc file so that any server that gets spun up gets the benefit.

Thanks to IPv6 shorthand notation, there is an even shorter version, though arguably it's harder to type:

php -S [::1]:8008