Symfony is linked to the wrong PHP version

If it's your web application that's using the wrong version of PHP, this is an Apache configuration issue. If it's the command line, this is actually a pretty easy thing to fix, you just need to make sure that /opt/rh/php55/root/usr/bin/ is in your $PATH before /usr/bin.

You can do this in your ~/.bashrc or ~/.bash_profile with this:

export PATH=/opt/rh/php55/root/usr/bin:$PATH

Just put that at the end, log out and in again. You can also just pop that in your command line directly, but it'll only apply for the current session, so the ~/.bashrc or ~/.bash_profile options are better.


I know this is old, but I had the same issue of Symfony using an older PHP version (7.1 in my case, the default with OSX Mojave) than I had installed. My $PATH variable pointed to the newer 7.2 version and php -v showed 7.2 and still Symfony used 7.1.

It looks like this was solved when I ran:

symfony local:php:list

It listed all the PHP versions on my system and it had 7.2 marked as default. After running this and executing symfony server:start it was on 7.2.

The php:list command also give useful instructions on setting a specific PHP version for a project:

To control the version used in a directory, create a .php-version file that contains the version number (e.g. 7.2 or 7.2.15). If you're using SymfonyCloud, the version can also be specified in the .symfony.cloud.yaml file.


I had the same problem when I did symfony serve.

First I ran symfony local:php:list to know which version of php my project used.

Then I ran echo 7.4.9 > .php-version (7.4.9 is the latest php version I downloaded) to switch the php version of my project.

It works fine for me.