Roots Discourse

Update PHP


#1

Hey there,

I was just trying to install MWDelaney/sage-bootstrap4-navwalker and composer spat out an error:

Problem 1
- This package requires php >=7.2 but your PHP version (7.1.19) does not satisfy that requirement.

How can I go about bumping the version of PHP from 7.1.x to 7.2.x? Should I just update Trellis instead (although I’ve done that once before and it wasn’t much fun!)

Many thanks!


#2

I think you can change these to php-7.2 from php-7.1. (You could look at the same file on master for reference: https://github.com/roots/trellis/blob/master/roles/php/defaults/main.yml). Then you should just be able to re-provision and it’ll switch to PHP 7.2. You may need to manually stop 7.1 and start 7.2 once after the re-provision (I had to do this a couple times when updating PHP, but that issue may have been solved since then).

The tasks.yaml file on master for the Trellis PHP roles may also be helpful, since it lays out how PHP is installed and updated: https://github.com/roots/trellis/blob/master/roles/php/tasks/main.yml


#3

Thanks for the pointers @alwaysblank - I was poking around in Trellis and it did look like PHP 7.2 was already set as the default, which I have now confirmed it is…

phpinfo.php shows this:

PHP Version 7.2.9-1+ubuntu16.04.1+deb.sury.org+1

Which begs the question… what’s going on!

Any ideas why running

composer require "mwdelaney/sage-bootstrap4-navwalker"

from site/ on a Tellis, Bedrock & Sage 9 stack might return this?

$ composer require "mwdelaney/sage-bootstrap4-navwalker"

Using version ^1.2 for mwdelaney/sage-bootstrap4-navwalker
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- This package requires php >=7.2 but your PHP version (7.1.19) does not satisfy that requirement.


Installation failed, reverting ./composer.json to its original content.

#4

Alright, I’m an idiot - I’ll leave the proof here for future generations…

I had changed my Bedrock composer.json to require php >= 7.2 which was causing the issue.

Ooops. Thanks for your help though @alwaysblank

EDIT
I think the reference to PHP 7.1.19 not satisfying the requirements refers to the version of PHP installed on my mac - I’m not sure how this plays into anything, or why its referenced over PHP installed on the vagrant machine, but worth noting nonetheless. I guess I’m still a little confused about how all of this works.


#5

If you use vagrant ssh to log into your VM and run composer whatever, it uses the version of PHP specified in Trellis. If you run composer whatever without sshing into your VM, it uses the version of PHP your Mac has. Running composer update in /site on your Mac will still use your Mac’s version of PHP–it doesn’t somehow reach into your VM and use that version.