composer.json - Explicitly set target PHP platform
authorTim Otten <totten@civicrm.org>
Wed, 29 Jan 2020 20:12:47 +0000 (12:12 -0800)
committerTim Otten <totten@civicrm.org>
Wed, 29 Jan 2020 20:24:23 +0000 (12:24 -0800)
Overview
--------

This refines the way in which `composer` resolves dependencies - so as to
prefer packages that are compatible with Civi's declared minimum requirement.

https://blog.martinhujer.cz/17-tips-for-using-composer-efficiently/#tip-%2315%3A-specify-the-production-php-version-in-%60composer.json%60

Before
------

Suppose that:

* The current minimum declared is PHP 7.0. (That happens to be the case at time of writing.)
* You locally use PHP 7.4.
* You wish to add or update a package.

`composer` may grab a version of a package that works on PHP 7.4 -- but is
not available/compatible with PHP 7.0. Then you start developing things under
the false expectation that the library will be usable -- and only discover the
problem later.

After
-----

`composer` should grab packages that are compatible with the declared PHP version,
regardless of the local PHP version.

Comment
-------

* This is orthogonal to the question of *which* PHP version should be the
  platform for CiviCRM -- whatever version that is, this dynamic can play out.
  The patch doesn't change that.
* The value will undoubtedly change over time, which has a small maintenance
  issue to keep the PHP constants in sync with the composer metadata.
  KISS solution: add a comment!

CRM/Upgrade/Form.php
composer.json
composer.lock

index 4d9f5ea5f55ec040c60d9321dbe4940be9adef00..ab3de5688f6b734c6a740927c9735c6bf9acbb56 100644 (file)
@@ -35,6 +35,8 @@ class CRM_Upgrade_Form extends CRM_Core_Form {
    * Minimum php version required to run (equal to or lower than the minimum install version)
    *
    * As of Civi 5.16, using PHP 5.x will lead to a hard crash during bootstrap.
+   *
+   * Tip: Keep in sync with composer.json ("config => platform => php")
    */
   const MINIMUM_PHP_VERSION = '7.0.0';
 
index ff3e3da5d4302a2b033f7d4f2b019ae3578d2e1f..78ce893b09fec389acd21072ca5a92b21a2d986c 100644 (file)
     }
   },
   "include-path": ["vendor/tecnickcom"],
+  "config": {
+    "platform": {
+      "php": "7.0.10"
+    }
+  },
   "require": {
     "php": "~7.0",
     "dompdf/dompdf" : "0.8.*",
index d9851b94f54a6a43b4c7586e2c89e17c92e8854c..2d0c8a6f2f4c50464dd424fc14cfe771b87de489 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "112c1a1b713a206d1e9d5195f150fa32",
+    "content-hash": "b00b30a1ff5e53daf097978e3940c067",
     "packages": [
         {
             "name": "civicrm/civicrm-cxn-rpc",
                 "mimetype",
                 "php"
             ],
+            "abandoned": true,
             "time": "2017-03-23T02:05:33+00:00"
         },
         {
             "version": "3.0.0+php53",
             "dist": {
                 "type": "zip",
-                "url": "https://github.com/tplaner/When/archive/c1ec099f421bff354cc5c929f83b94031423fc80.zip",
-                "reference": null,
-                "shasum": null
+                "url": "https://github.com/tplaner/When/archive/c1ec099f421bff354cc5c929f83b94031423fc80.zip"
             },
             "require": {
                 "php": ">=5.3.0"
     "platform": {
         "php": "~7.0"
     },
-    "platform-dev": []
+    "platform-dev": [],
+    "platform-overrides": {
+        "php": "7.0.10"
+    }
 }