Change PHP version

Is it possible to change PHP version, that Trellis sites will actually use?

I’ve found pull request for upgrade to PHP 7.2: https://github.com/roots/trellis/pull/929. I’ve edited my local files manually and ran vagrant reload --provision. Provisioning completed without any problems.

I’ve also set "php": "~7.2" as a dependency in my composer.json file.

vagrant ssh shows php --version as “PHP 7.2.1-1+ubuntu16.04.1+deb.sury.org+1”. In my “non-virtual” environment, php --version prints PHP 7.2.1 (cli). However when I print phpversion() in code of my site, it still outputs 7.1.7-1+ubuntu16.04.1+deb.sury.org+1PHP.

Did I miss something? Or does something in my “non-virtual” environment overwrites Trellis config?

Thanks in advance!

1 Like

I’m not entirely sure what you mean by “non-virtual” environment.

I had a somewhat similar problem with a remote server that I resolved by restarting the php-fpm service on the server. In your case, you’d do that by vagrant sshing into your VM, and running commands that look kind of like this:

sudo service php7.1-fpm stop
# some output...
sudo service php7.2-fpm start
# some more output...
2 Likes

I’ve had this problem before when updating Trellis, and suggested awhile ago it might be a nice idea for during provision to check if an outdated version of PHP is running first, disable it and start the newer version. Trellis doesn’t seem to do this for you.

I know it’s not something that happens often, but still…

1 Like

Thanks for superfast responses! stop/start commands after vagrant ssh worked.

Yeah the main reason that 7.2 PR isn’t merged because I wanted to have this functionality. Just installing 7.2 works (with restarting some services) but it leaves behind everything 7.1 which isn’t ideal.

1 Like

Is there similar restart command fox XDebug?

Not that I’m aware of. I don’t believe that XDebug runs its own processes that would need restarting: I think restarting the server process (so, nginx on a normal Trellis setup) should cause XDebug to be reloaded (or whatever). What problem are you hoping to resolve by doing so? You didn’t provide much information.

PHP error reporting does not seem to be parsed by XDebug anymore (simply put, there are no orange tables anymore). I’m not familiar with other XDebug functions I could test - so I’m not sure if no xdebug features are working, or just error reporting.

As I’ve written above, I’ve edited my Trellis provisiong files manually according to this PR request, so it is very possible that I overlooked something in the process.

I’ve ran provisioning process several times (I was adding more sites to my setup) and it finished without problems, however XDebug still doesn’t seem to parse errors.

Thanks in advance!

Actually, it seems I’ve overlooked note about this from author of the PR, sorry! https://github.com/oerdnj/deb.sury.org/issues/751

The PR you linked to says that XDebug is not officially available for PHP 7.2 because the version of XDebug that adds support for 7.2 isn’t out of development. You can try and install/compile it yourself, if you want. This thread has some suggestions: https://github.com/oerdnj/deb.sury.org/issues/751. Unless you specifically need 7.2 features, though, you might want to downgrade to 7.1 if no XDebug is a deal breaker.

1 Like