jlevers / selling-partner-api

A PHP client library for Amazon's Selling Partner API
BSD 3-Clause "New" or "Revised" License
398 stars 185 forks source link

Compose / PHP version issue #554

Closed kristianstout closed 1 year ago

kristianstout commented 1 year ago

The library is supposed to be able to run on PHP 7.3 but composer dependencies are requiring 8.1 minimum. Is there any way to install a fully 7.3 compatible version of this library?

jlevers commented 1 year ago

What is Composer telling you is the conflicting package? A quick look makes me think that it's PHPSpreadsheet, but I'm having a hard time testing as I can't get PHP 7.3 to build on my machine with phpenv.

kristianstout commented 1 year ago

this is what I get when I try running your test code:

%> /Applications/MAMP/bin/php/php7.3.33/bin/php test.php Composer detected issues in your platform:

Your Composer dependencies require a PHP version ">= 8.1.0". You are running 7.3.33.

is there a way I can get a more verbose output on this to help you figure out which lib it is ?

jlevers commented 1 year ago

If you try removing the package from your project with composer remove jlevers/selling-partner-api, and then install it again with composer require jlevers/selling-partner-api, I think you might get some output telling you what packages are causing the conflict...give that a try and let me know what you get.

kristianstout commented 1 year ago

I actually did a reinstall before replying this morning and still have that output:

composer require jlevers/selling-partner-api ./composer.json has been created Running composer update jlevers/selling-partner-api Loading composer repositories with package information Updating dependencies Lock file operations: 20 installs, 0 updates, 0 removals

kristianstout commented 1 year ago

also im happy to try modifying library loading or something in the libraries if you have some idea for how I can systematically test it on my side.

kristianstout commented 1 year ago

any idea what I can do here? is there a library I can prevent from installing or perhaps modify the composer files manually on my side?

jlevers commented 1 year ago

Whoops, sorry – forgot to follow up here. I removed the AWS SDK from the library, as that was causing some other versioning issues, and I think it could have been the culprit of this issue too. Could you try installing the latest version and trying again?

kristianstout commented 1 year ago

same error:

php test.php Composer detected issues in your platform:

Your Composer dependencies require a PHP version ">= 8.1.0". You are running 7.3.33.

new install messages:

composer require jlevers/selling-partner-api
Info from https://repo.packagist.org: #StandWithUkraine ./composer.json has been created Running composer update jlevers/selling-partner-api Loading composer repositories with package information Updating dependencies Lock file operations: 16 installs, 0 updates, 0 removals

  • Locking ezyang/htmlpurifier (v4.16.0)
  • Locking guzzlehttp/guzzle (7.7.0)
  • Locking guzzlehttp/promises (2.0.0)
  • Locking guzzlehttp/psr7 (2.5.0)
  • Locking jlevers/selling-partner-api (5.9.0)
  • Locking maennchen/zipstream-php (v2.4.0)
  • Locking markbaker/complex (3.0.2)
  • Locking markbaker/matrix (3.0.1)
  • Locking myclabs/php-enum (1.8.4)
  • Locking phpoffice/phpspreadsheet (1.28.0)
  • Locking psr/http-client (1.0.2)
  • Locking psr/http-factory (1.0.2)
  • Locking psr/http-message (1.1)
  • Locking psr/simple-cache (3.0.0)
  • Locking ralouphie/getallheaders (3.0.3)
  • Locking symfony/deprecation-contracts (v3.3.0) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 16 installs, 0 updates, 0 removals
  • Installing guzzlehttp/promises (2.0.0): Extracting archive
  • Installing ralouphie/getallheaders (3.0.3): Extracting archive
  • Installing psr/http-message (1.1): Extracting archive
  • Installing psr/http-factory (1.0.2): Extracting archive
  • Installing guzzlehttp/psr7 (2.5.0): Extracting archive
  • Installing psr/simple-cache (3.0.0): Extracting archive
  • Installing psr/http-client (1.0.2): Extracting archive
  • Installing markbaker/matrix (3.0.1): Extracting archive
  • Installing markbaker/complex (3.0.2): Extracting archive
  • Installing myclabs/php-enum (1.8.4): Extracting archive
  • Installing maennchen/zipstream-php (v2.4.0): Extracting archive
  • Installing ezyang/htmlpurifier (v4.16.0): Extracting archive
  • Installing phpoffice/phpspreadsheet (1.28.0): Extracting archive
  • Installing symfony/deprecation-contracts (v3.3.0): Extracting archive
  • Installing guzzlehttp/guzzle (7.7.0): Extracting archive
  • Installing jlevers/selling-partner-api (5.9.0): Extracting archive 7 package suggestions were added by new dependencies, use composer suggest to see details. Generating autoload files 6 packages you are using are looking for funding. Use the composer fund command to find out more! No security vulnerability advisories found Using version ^5.9 for jlevers/selling-partner-api
kristianstout commented 1 year ago

looking through the composer.lock file, it looks like the problem is symfony


 {
            "name": "symfony/deprecation-contracts",
            "version": "v3.3.0",
            "version_normalized": "3.3.0.0",
            "source": {
                "type": "git",
                "url": "https://github.com/symfony/deprecation-contracts.git",
                "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf",
                "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf",
                "shasum": ""
            },
            **"require": {
                "php": ">=8.1"
            },**
            "time": "2023-05-23T14:45:45+00:00",
            "type": "library",
            "extra": {
                "branch-alias": {
                    "dev-main": "3.4-dev"
                },
                "thanks": {
                    "name": "symfony/contracts",
                    "url": "https://github.com/symfony/contracts"
                }
            },
kristianstout commented 1 year ago

so to continue in my exploration. I commented out these lines in platform_check and was able to successfully pull down orders. so it looks like I. might be able to get at least some functions running in 7.3.33.

if (!(PHP_VERSION_ID >= 80100)) { $issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.'; }

jlevers commented 1 year ago

Were you able to figure out which package was using symfony/contracts?

kristianstout commented 1 year ago

not yet - I got sample code working with pulling down an order list and didnt hit an error. I am trying to figure out how to list items now - once I run that code I'll see if I hit an error in php versions. if you have any sample code for showing how to do the listings I wouldn't complain! I am currently migrating old MWS XML posting for product data, inventory, pricing, and images over to SP-API. im starting with the inventory one

kristianstout commented 1 year ago

just an fyi - I was away but will be working on this this week, so if you have any sample code for pushing listing id love to have it to speed up testing the symfony testing

dathat commented 1 year ago

It looks like guzzlehttp/guzzle is the package requiring symfony/deprecation-contracts:

{
            "name": "guzzlehttp/guzzle",
            "version": "7.7.0",
            "source": {
                "type": "git",
                "url": "https://github.com/guzzle/guzzle.git",
                "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/guzzle/guzzle/zipball/fb7566caccf22d74d1ab270de3551f72a58399f5",
                "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5",
                "shasum": ""
            },
            "require": {
                "ext-json": "*",
                "guzzlehttp/promises": "^1.5.3 || ^2.0",
                "guzzlehttp/psr7": "^1.9.1 || ^2.4.5",
                "php": "^7.2.5 || ^8.0",
                "psr/http-client": "^1.0",
                "symfony/deprecation-contracts": "^2.2 || ^3.0"
            },
            "provide": {
                "psr/http-client-implementation": "1.0"
            },
            "require-dev": {
                "bamarni/composer-bin-plugin": "^1.8.1",
                "ext-curl": "*",
                "php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999",
                "php-http/message-factory": "^1.1",
                "phpunit/phpunit": "^8.5.29 || ^9.5.23",
                "psr/log": "^1.1 || ^2.0 || ^3.0"
            },
            ...

I have little experience with package systems, and less with composer... "symfony/deprecation-contracts": "^2.2 || ^3.0" means it can use the v2.2 package though, right? It looks like that one only requires php >= 7.1.

Is there a way to make composer use the lower version for the requirement of a requirement? Stuck on a lower php version to keep old MWS stuff running. Just trying to do quick side-by-side testing before bumping the server to php8.1 or 8.2 anyway.

edit: There are two other packages also requiring php7.4+ with the default composer install. To work on php7.3 "phpoffice/phpspreadsheet" needs to be downgraded to 1.25.2 or lower and "psr/simple-cache" (required by "phpoffice/phpspreadsheet") needs to be downgraded to v1.0.1.

jlevers commented 1 year ago

Thanks @dathat – I fixed the phpoffice/phpspreadsheet version to 1.25.2 in the latest library release (v5.10.2). To ensure that you're getting the correct package versions for your PHP version, add something like this to your composer.json:

"config": {
    "platform": {
        "php": "7.3.0"
    }
}

Then run composer update.