Categories
guides

WP-CLI PHP Version

Issue

phpinfo() via browser reports a different version of PHP than wp —info or php -v reports in cli.

Reason

The CLI version of PHP is found via the $PATH variable, where as the browser version is being found by Apache config. To change the CLI version, I needed to update my $PATH to find the correct version first. I did this by adding the location of the binary to the begging of the $PATH with:

set PATH=/path/to/bin:$PATH
export PATH=/path/to/bin:$PATH

I’m not sure both of these are required, but just the set did not work. Maybe export does something I don’t want? I’m not sure – but currently this is just on dev so it doesn’t matter.

To find the /path/to/bin of the PHP binary, I used print_r(get_defined_constants(true)) in a .php file in browser, and found the PHP_BINDIR constant in the output.

src

By bo.

I'm @boyEatsSteak in a lot of places. I have been wanting 🍕 for weeks. I like gadgets and technology and keeping notes and tips for my future self since all I can remember is that I forget things.