Search code examples
phpsymfonycomposer-phpsylius

Issues trying to install sylius/product-bundle to my Symfony 5.3 project with composer


I am trying to develop a project and I'm having trouble installing a Sylius with composer.

Here is my composer.json

{
    "type": "project",
    "license": "proprietary",
    "minimum-stability": "dev",
    "prefer-stable": true,
    "require": {
        "php": ">=7.0",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "composer/package-versions-deprecated": "1.11.99.2",
        "doctrine/annotations": "^1.0",
        "doctrine/doctrine-bundle": "^2.4",
        "doctrine/doctrine-migrations-bundle": "^3.1",
        "doctrine/orm": "^2.9",
        "phpdocumentor/reflection-docblock": "^5.2",
        "sensio/framework-extra-bundle": "^6.1",
        "symfony/apache-pack": "^1.0",
        "symfony/asset": "5.3.*",
        "symfony/console": "5.3.*",
        "symfony/dotenv": "5.3.*",
        "symfony/expression-language": "5.3.*",
        "symfony/flex": "^1.3.1",
        "symfony/form": "5.3.*",
        "symfony/framework-bundle": "5.3.*",
        "symfony/http-client": "5.3.*",
        "symfony/intl": "5.3.*",
        "symfony/mailer": "5.3.*",
        "symfony/mime": "5.3.*",
        "symfony/monolog-bundle": "^3.1",
        "symfony/notifier": "5.3.*",
        "symfony/process": "5.3.*",
        "symfony/property-access": "5.3.*",
        "symfony/property-info": "5.3.*",
        "symfony/proxy-manager-bridge": "5.3.*",
        "symfony/runtime": "5.3.*",
        "symfony/security-bundle": "5.3.*",
        "symfony/serializer": "5.3.*",
        "symfony/string": "5.3.*",
        "symfony/translation": "5.3.*",
        "symfony/twig-bundle": "^5.3",
        "symfony/validator": "5.3.*",
        "symfony/web-link": "5.3.*",
        "symfony/webpack-encore-bundle": "^1.11",
        "symfony/yaml": "5.3.*",
        "twig/extra-bundle": "^2.12|^3.0",
        "twig/twig": "^2.12|^3.0"
    },
    "require-dev": {
        "phpunit/phpunit": "^9.5",
        "symfony/browser-kit": "^5.3",
        "symfony/css-selector": "^5.3",
        "symfony/debug-bundle": "^5.3",
        "symfony/maker-bundle": "^1.0",
        "symfony/phpunit-bridge": "^5.3",
        "symfony/stopwatch": "^5.3",
        "symfony/var-dumper": "^5.3",
        "symfony/web-profiler-bundle": "^5.3"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "5.3.*"
        }
    }
}

When I type composer require sylius/product-bundle I get this error

Using version ^0.15.0 for sylius/product-bundle
./composer.json has been updated
Running composer update sylius/product-bundle
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires sylius/product-bundle ^0.15.0 -> satisfiable by sylius/product-bundle[v0.15.0].
    - sylius/product-bundle v0.15.0 requires symfony/framework-bundle ~2.3 -> found symfony/framework-bundle[v2.3.0, ..., 2.8.x-dev] but it conflicts with your root composer.json require (5.3.*).

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

So from what I understand, composer tries to fetch the version 0.15.0 of sylius/product-bundle, which obviously won't work with my configuration because it requires older versions of its dependencies, as shown below.

sylius/product-bundle v0.15.0

Only when I try to require a newer version with composer require sylius/product-bundle:1.9.4, I also get an error

  [InvalidArgumentException]
  Package sylius/product-bundle at version 1.9.4 has a PHP requirement incompatible with your PHP version, PHP extensions and Composer version

This one should have done the trick, given the required versions of its dependencies sylius/product-bundle v1.9.4

I finally tried with composer require sylius/product-bundle:1.9.4 --ignore-platform-reqs, which once again gives me an error, but a different one

./composer.json has been updated
Running composer update sylius/product-bundle
Loading composer repositories with package information
Restricting packages listed in "symfony/symfony" to "5.3.*"
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - gedmo/doctrine-extensions[v2.3.10, ..., v2.4.x-dev, v3.0.0-beta, ..., v3.0.1] require doctrine/common ~2.4 -> found doctrine/common[2.4.0-RC1, ..., 2.13.x-dev] but the package is fixed to 3.1.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - gedmo/doctrine-extensions[v2.3.4, ..., v2.3.9] require doctrine/common >=2.2,<2.5-dev -> found doctrine/common[2.2.0BETA1, ..., 2.4.x-dev] but the package is fixed to 3.1.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - gedmo/doctrine-extensions[v3.0.0-beta2, ..., v3.0.5] require doctrine/cache ^1.0 -> found doctrine/cache[v1.0, ..., 1.11.x-dev] but the package is fixed to 2.0.3 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - sylius/product-bundle v1.9.4 requires stof/doctrine-extensions-bundle ^1.4 -> satisfiable by stof/doctrine-extensions-bundle[v1.4.0, v1.5.0, v1.6.0, 1.6.x-dev (alias of dev-master)].
    - stof/doctrine-extensions-bundle 1.6.x-dev is an alias of stof/doctrine-extensions-bundle dev-master and thus requires it to be installed too.
    - stof/doctrine-extensions-bundle v1.4.0 requires gedmo/doctrine-extensions ^2.3.4 -> satisfiable by gedmo/doctrine-extensions[v2.3.4, ..., v2.4.x-dev].
    - stof/doctrine-extensions-bundle[dev-master, v1.5.0, ..., v1.6.0] require gedmo/doctrine-extensions ^2.3.4 || ^3.0.0 -> satisfiable by gedmo/doctrine-extensions[v2.3.4, ..., v2.4.x-dev, v3.0.0-beta, ..., v3.0.5].
    - Root composer.json requires sylius/product-bundle 1.9.4 -> satisfiable by sylius/product-bundle[v1.9.4].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

I got PHP cli v8.0.6, Composer v2.0.12 and Symfony cli v4.25.2


Solution

  • You have two problems:

    • You have Symfony '5.3' installed, which was released just one day ago.
    • You are using PHP 8, which is not supported by Sylius. By using PHP 8, you end up installing versions of dependencies that are not compatible with Sylius.

    Since the current version of Sylius supports up to 5.2, and PHP ^7.3, you'll have to either downgrade to Sf 5.2 and PHP >= 7.3 && PHP < 8, or wait a some time so support for Sf 5.3 and PHP >= 8 is baked in.

    I would recommend using the standard Sylius installation, but trying to install Sylius with the recommended docs way (composer create-project sylius/sylius-standard acme) when using PHP 8 also fails. But downgrading to PHP 7.4 and running the create-project command does work.

    The project seems to have entered the dependency hell stage of development.