How to set or change the $PATH environment variable in PHP

In my case I am using vorbiscomment to explain the issue when binaries are not located within the paths defined in the environment path variable.

If I would var_dump() the output of vorbiscomment it would return ‘null’.


This is caused by the vorbiscomment not found in the environment path variable.

Lets check the output of getenv() with the use of var_dump().


My output would be:


I know that vorbiscomment is located in ‘/usr/local/bin’.
So, lets add that path to the variable by using putenv() but keep the already defined paths using getenv().


Again run the var_dump() and you will notice this change.


The output of vorbiscomment:


So, great, lets finish my ogg editor now 😀