How to set environment variables for a PHP Command line app
It’s pretty simple really.
instead of doing this..
php application.php
you can then do this
export ENVIRONMENT_VAR=test; php application.php
Getting this variable from within PHP is easy - just do a search for the getenv() function ;)
UPDATE!
Ok, this works too, with the added advantage of not setting the variable permanently!
ENVIRONMENT_VAR=test php application.php
Note that there are no semi colons between the variable and the php command.