gabrieluk Posted April 17, 2022 Share Posted April 17, 2022 I need to implement T-Regx library - https://github.com/T-Regx/T-Regx - in a project that might be running in PHP 5.6 or PHP 7.1+, depending on which version the server has installed. So, on PHP 5.6, I need to run package #1 and on PHP 7.1+ package #2. However, whenever I install the package it creates the directory /vendor/rawr/t-regx/ - I need to have something like /vendor/rawr/t-regx-5.6/ and /vendor/rawr/t-regx-7-1-plus/ and composer should trigger the needed one based on the PHP version. I need this because plenty of people still use PHP 5.6 and I can't just tell them to upgrade (it's not that simple). If I use a PHP 5.6 package and the user has PHP 8 installed, there will be errors shown that would annoy the user. Any suggestions? I'm sure other users are having this issue. Quote Link to comment https://forums.phpfreaks.com/topic/314709-how-to-install-two-packages-of-the-same-library-in-composer-and-have-each-run-depending-on-the-php-version/ Share on other sites More sharing options...
kicken Posted April 17, 2022 Share Posted April 17, 2022 If you install it on the target system with composer, then composer will install whichever version of the package is compatible automatically, just make sure you have your version constraint for the package setup correctly. If you're trying to pre-package a release and want to make a 5.6 version and 7.1 version, you could have both version of PHP installed and run composer with the appropriate version. Quote Link to comment https://forums.phpfreaks.com/topic/314709-how-to-install-two-packages-of-the-same-library-in-composer-and-have-each-run-depending-on-the-php-version/#findComment-1595443 Share on other sites More sharing options...
gabrieluk Posted April 17, 2022 Author Share Posted April 17, 2022 That will not work because this is to be implemented in a WordPress plugin that is installed on various websites either having PHP 5.6 or PHP 7.1+. So, it needs to have both versions installed and detect which PHP version is used and load the package accordingly. This can be easily done in PHP, but when it comes to Composer, I need to implement this effectively and I'm out of ideas. The library they provide work well with Composer and they highly recommend it. Quote Link to comment https://forums.phpfreaks.com/topic/314709-how-to-install-two-packages-of-the-same-library-in-composer-and-have-each-run-depending-on-the-php-version/#findComment-1595446 Share on other sites More sharing options...
requinix Posted April 17, 2022 Share Posted April 17, 2022 Provide two versions of the plugin. Quote Link to comment https://forums.phpfreaks.com/topic/314709-how-to-install-two-packages-of-the-same-library-in-composer-and-have-each-run-depending-on-the-php-version/#findComment-1595448 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.