Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regarding the issue with the PHP Cooper version #1071

Open
ajiho opened this issue Sep 7, 2024 · 1 comment
Open

Regarding the issue with the PHP Cooper version #1071

ajiho opened this issue Sep 7, 2024 · 1 comment

Comments

@ajiho
Copy link

ajiho commented Sep 7, 2024

My composer library has the following restrictions on PHP

{
  "require": {
    "php": ">=7.2",
    "fakerphp/faker": "^1.20.0"
  },
}

If my local PHP version is PHP7.2, then I can only install php-scoper version for PHP7 through Composer e.g php-scoper v0.13.9

If I upgrade my local PHP version to 8.2. x and then install the latest version of php-scoper e.g php-scoper v0.18.5 . Used to obtain the latest options and feature support for php-scoper and add prefixes to the code, will it cause damage to my composer library? Is this usage method correct?

@daika7ana
Copy link

daika7ana commented Sep 25, 2024

Considering your project has a "php": ">=7.2" requirement, upgrading to 8.2 shouldn't break anything since it's within it's constraints. Also, any damage done to the installed packages can be undone by removing the vendor folder and running composer install again.

That being said, what I would suggest from a production standpoint is:

  1. What I used to do in the past is have multiple php versions locally:
    The one you use to run composer update/install on the project which is 7.2 in your case and run it with /usr/bin/php72 $(which composer) update or whichever dir you installed the php version required for composer.
    And then the other php version (8.2) php-scoper /usr/bin/php82 php-scoper.phar add-prefix ....
    This way both project/composer and php-scoper run on the required php versions.

  2. The other way, and the way I am doing it now is locking the platform's php version by editing my project's composer.json and adding the following section:

{
  ....
  "config": {
    "platform": {
      "php": "7.2.34"
    }
  },
}

This way, I can run a single php version (8.2) but composer will always require packages versions compatible with the specified php version (7.2 in this case), because he thinks I am using the specified version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants