(dev/drupal#79) Fail more gracefully when attempting to install on PHP 5.x
authorTim Otten <totten@civicrm.org>
Wed, 21 Aug 2019 02:48:41 +0000 (19:48 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 21 Aug 2019 02:48:41 +0000 (19:48 -0700)
commit1f18062168407d22d5057ce5718bc807378e1547
treed80ec6351f5a3b9a6f224d7729439dc48f928571
parenta9c0826f87ca68ef1d456fa67c586a3fec37f01d
(dev/drupal#79) Fail more gracefully when attempting to install on PHP 5.x

Before
------

If an admin stracts the code and navigates to `/sites/all/modules/civicrm/install/index.php`, it displays
a syntax error.

After
-----

If an admin stracts the code and navigates to `/sites/all/modules/civicrm/install/index.php`, it displays
the message:

> __PHP Version Requirement__
> CiviCRM requires PHP 7.0+. The web server is running PHP 5.6.38.

Comments
--------

This is similar to https://github.com/civicrm/civicrm-drupal/pull/583

The canonical representation of the minimum PHP version is in
`$civicrm_root/CRM/Upgrade/Form.php`.  However, setting up the classloader
triggers a syntax error, so we need to read this without having access to
the classloader.

The approach herein has a few effects:

* The minimum PHP can be read from a JSON file.
* That JSON file is also used by `composer`, so you'll also get better errors when downloading that way.
* At some unknown point, the minimum will probably bump up again (7.1 or 7.2 or whatever). When that
  happens, the unit-test will ensure we keep `CRM/Upgrade/Form.php` and `composer.json` in sync.

Note: I was little concerned that the `composer.json` file might not be
available when normal installers run, so I checked the published tarballs
for D7, BD, WP, and J - in all cases, the `composer.json` looks to be
included at the expected location.
composer.json
install/index.php
tests/phpunit/CRM/Upgrade/FormTest.php [new file with mode: 0644]