0

I want to have an app in symfony 3.4, but to have symfony/dotenv in v4. The dotenv package in version 4.4.8 supports symfony/process 3.4.

But when I run composer update, it fails and only lists 3.4.* as candidate versions. This is probably restricted by extra.symfony.require: 3.4.* in composer.json.

I know it works at least in some cases. I have a project in symfony 3.4 which uses symfony/http-client 4.3. Does this only work because there is no older version?

Where can I find more information about dependency restricting by symfony/flex?

Here are some sources I know:

  1. https://symfonycasts.com/screencast/symfony5-upgrade/version-constraints#symfony-flex-symfony-extra-require-is-a-soft-requirement
  2. https://github.com/symfony/flex/blob/master/README.md
  3. https://flex.symfony.com/

And here the clearest one:

  1. How composer `extra.symfony.require` restriction is enforced?

When extra.symfony.require is a soft requirement (text from 1.), what does this mean? Does this match to 4.?


example of composer.json which fails to run composer require symfony/dotenv:^4.0 (created with symfony new --version=3.4):

{
    "type": "project",
    "require": {
        "php": "^7.0.8",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "symfony/console": "3.4.*",
        "symfony/dotenv": "3.4.*",
        "symfony/flex": "^1.3.1",
        "symfony/framework-bundle": "3.4.*",
        "symfony/yaml": "3.4.*"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "3.4.*"
        }
    }
}
simohe
  • 613
  • 7
  • 20
  • If you want to install `symfony/dotenv` in v4, you should require it. Running `composer update` won't do that – Nico Haase May 08 '20 at 19:25
  • I edited composer.json by hand. So `composer update` would update (if it could). When I run `composer require symfony/dotenv:^4.0` instead, it fails as well. The error message says `Could not find package symfony/dotenv in a version matching ^4.0`. – simohe May 13 '20 at 06:35
  • Please share more details, for example the current state of your `composer.json`. As you can see on https://packagist.org/packages/symfony/dotenv, there are package versions matching `^4.0`, so I think the problem lies in any other part – Nico Haase May 13 '20 at 07:22
  • composer.json is in question now. I still think that this is restricted by `extra.symfony.require`. When I delete this, then it works. But then I get a mixture of symfony component versions. – simohe May 13 '20 at 07:42
  • Well, yeah, obviously. That line tells you that Symfony packages should match `3.4.*` - have you tried installing `symfony/dotenv:^3.4`? – Nico Haase May 13 '20 at 07:52
  • Of course the matching version of symfony/dotenv works. My question still is: Why does it work with `symfony/http-client:^4.3` but not with `symfony/dotenv:^4.0`. And already in the original question I suppose *Does this only work because there is no older version?*. – simohe May 15 '20 at 07:13
  • according to https://symfonycasts.com/screencast/symfony5-upgrade/version-constraints#comment-4914776956 (comment to my question in 1.), it is a soft requirement for upgrades, but NOT for installations. -- I am almost sure that `symfony/http-client:^4.3 ` worked because there is no older version. – simohe Jun 10 '20 at 12:32

0 Answers0