General developer forum

A way for plugins to specify PHP version

 
Picture of Oleg Sychev
A way for plugins to specify PHP version
Core developersPlugin developers

We have a strange problem - PHP 5.6.x has a bug that leads to crash in our code. And it is a result of the stupid API change, they refuse to fix it in 5.6.x branch, and since there seems to be no PHP 5.7 it means our plugins should be installed on PHP 7 only for later Moodle versions. 

Can we specify PHP version requirements for our release to exclude PHP 5.6.x somehow? And for people running PHP 5.6.x to avoid updating their installation (otherwise they'll lose function - automatic update can be devastating). I have seen PHP version fields in Moodle plugin database, but do not know are they actually checked and enforced during installation or just informational.

 
Average of ratings: -
Picture of Marina Glancy
Re: A way for plugins to specify PHP version
Core developersMoodle HQParticularly helpful MoodlersPlugin developersTesters

Hello Oleg,

yes you can. Please refer to https://docs.moodle.org/dev/Plugin_files#environment.xml

Moodle core itself has a minimum PHP version, for example, for Moodle 3.4 it is PHP 7.0:

https://github.com/moodle/moodle/blob/master/admin/environment.xml#L2099..L2100

 
Average of ratings: Useful (2)
Picture of Oleg Sychev
Re: A way for plugins to specify PHP version
Core developersPlugin developers

Thanks, Marina.

I guess we can't write in this file "use PHP 5.5.x or 7.x" and so have to lock our plugin at 7.x to avoid problems.

 
Average of ratings: -
Picture of Matteo Scaramuccia
Re: A way for plugins to specify PHP version
Core developersParticularly helpful MoodlersPlugin developers

Hi Oleg,
a Custom Check could be a better path: https://docs.moodle.org/dev/Environment_checking#Custom_checks.
Never tried by myself.

HTH,
Matteo

 
Average of ratings: -