I often use PHP built-in web server for my PHP projects during testing and development phase. The PHP projects in many cases using environment variable to define configuration or controlling app behaviour (e.g. running on prod or test environment).
Setting environment variable can be done like this on Linux.
If you want to set environment variable during the start of PHP built-in web server just type like this.
MYENV=myvalue php -S 0.0.0.0:8000
For setting multiple environment variables can be done like below.
MYENV=myvalue MYOTHERENV=myothervalue php -S 0.0.0.0:8000
If above not working, try this one as well.
MYENV=myvalue php -d variables_order=EGPCS -S 0.0.0.0:8000
On PHP you can get the environment variable with this code.
<?php echo getenv('MYENV');
On Windows you can do that via git-bash shell.
Thank you and I hope you enjoy it.