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

Composer dependencies not using correct PHP version #6

Open
ragulka opened this issue Apr 23, 2024 · 1 comment
Open

Composer dependencies not using correct PHP version #6

ragulka opened this issue Apr 23, 2024 · 1 comment

Comments

@ragulka
Copy link

ragulka commented Apr 23, 2024

I'm trying to make sure that any composer dependencies that get installed work with PHP 7.4 - for comptibility reasons. I have defined the platform (as well as php version) in both composer.json and composer-deps.json:

composer.json

{
    "autoload": {
        "psr-4": {
            "MyPlugin\\": "src/"
        }
    },
    "require": {
        "php": "^7.4 || ^8.0"
    },
    "extra": {
        "wpify-scoper": {
            "prefix": "MyDeps",
            "folder": "deps",
            "globals": [
                "wordpress",
                "woocommerce"
            ],
            "expose-global-constants": true,
            "composerjson": "composer-deps.json",
            "composerlock": "composer-deps.lock",
            "autorun": true
        }
    },
    "require-dev": {
        "wpify/scoper": "*"
    },
    "scripts": {
        "wpify-scoper": "wpify-scoper"
    },
    "config": {
        "platform": {
            "php": "7.4"
        },
        "allow-plugins": {
            "wpify/scoper": true,
            "php-http/discovery": true
        }
    }
}

composer-deps.json

{
    "config": {
        "platform": {
          "php": "7.4"
        }
    },
    "require": {
        "php": "^7.4 || ^8.0",
        "illuminate/support": "^8.83"
    }
}

However, after composer update, and trying to visit the site I get the composer platform check error:

Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0". You are running 7.4.33.

I would expect that dependencies should not require PHP 8.1 if my platform is set to 7.4.

Is there a way to work around or fix this?

@ragulka
Copy link
Author

ragulka commented Apr 24, 2024

The culprit here seems to be the fact that I was requiring wpify/scoper locally:

    "require-dev": {
        "wpify/scoper": "*"
    },

I now tried removing it and composer global require wpify/scoper and the dependencies are installed using the correct version now.

FWIW, trying to use version 3.1.3 of wpify/scoper in require-dev did not work - it would still install dependencies that required PHP 8.1, even if was actually running PHP 7.4

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

1 participant