laminas/laminas-code 4.3.0 需要 php ^7.4 || ~8.0.0 使用 symfony

分享于2022年10月08日 php symfony 问答
【问题标题】:laminas/laminas-code 4.3.0 requires php ^7.4 || ~8.0.0 using symfonylaminas/laminas-code 4.3.0 需要 php ^7.4 || ~8.0.0 使用 symfony
【发布时间】:2022-10-02 18:53:59
【问题描述】:

我有一个 symfony version 5 项目,我想将它安装在我的电脑窗口中,我将我的文件夹复制到 wamp/www ,我执行 cmd composer insatll 它给了我错误: curl error 6 while downloading https://flex.symfony. com/versions.json: Couldn\'t resolve host name ,我搜索我找到的解决方案在 link1 中,解决方法是执行 cmd composer update symfony/flex --no-plugins --no-scripts ,它会产生另一个错误:

laminas/laminas-code 4.3.0 requires php ^7.4 || ~8.0.0 -> your php version (7.3.5) does not satisfy that requirement.
    - symfony/proxy-manager-bridge v5.3.0 requires friendsofphp/proxy-manager-lts ^1.0.2 -> satisfiable by friendsofphp/proxy-manager-lts[v1.0.5].
    - friendsofphp/proxy-manager-lts v1.0.5 requires laminas/laminas-code ~3.4.1|^4.0 -> satisfiable by laminas/laminas-code[4.3.0].
    - symfony/proxy-manager-bridge is locked to version v5.3.0 and an update of this package was not requested 

. 我也搜索这个错误我发现 link2 解决方案是修改 composer.json

\"require\": {
        \"php\": \">=7.2.5\",
         .
        .
}

经过 :

\"required\": {
        \"php\": \"^7.3|^8.0\",
    .
    .

我运行 cmd composer dump-autoload ,然后我再次运行 composer update symfony/flex --no-plugins --no-scripts 但错误 - laminas/laminas-code 4.3.0 requires php ^7.4 || ~8.0.0 -> your php version (7.3.5) does not satisfy that requirement 仍然存在。

作曲家.json:

{
    \"type\": \"project\",
    \"license\": \"proprietary\",
    \"minimum-stability\": \"stable\",
    \"prefer-stable\": true,
    \"require\": {
        \"symfony/flex\": \"^1.1\",
        \"php\": \"^7.3|^8.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/asset\": \"5.3.*\",
        \"symfony/console\": \"5.3.*\",
        \"symfony/dotenv\": \"5.3.*\",
        \"symfony/expression-language\": \"5.3.*\",
        \"symfony/form\": \"5.3.*\",
        \"symfony/framework-bundle\": \"5.3.*\",
        \"symfony/google-mailer\": \"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/requirements-checker\": \"^2.0\",
        \"symfony/runtime\": \"5.3.*\",
        \"symfony/security-bundle\": \"5.3.*\",
        \"symfony/serializer\": \"5.3.*\",
        \"symfony/string\": \"5.3.*\",
        \"symfony/swiftmailer-bundle\": \"^3.5\",
        \"symfony/translation\": \"5.3.*\",
        \"symfony/twig-bundle\": \"^5.3\",
        \"symfony/validator\": \"5.3.*\",
        \"symfony/web-link\": \"5.3.*\",
        \"symfony/yaml\": \"5.3.*\",
        \"tattali/calendar-bundle\": \"^1.2\",
        \"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,
        \"allow-plugins\": {
            \"symfony/flex\": true,
            \"symfony/runtime\": 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\",
            \"requirements-checker\": \"script\"
        },
        \"post-install-cmd\": [
            \"@auto-scripts\"
        ],
        \"post-update-cmd\": [
            \"@auto-scripts\"
        ]
    },
    \"conflict\": {
        \"symfony/symfony\": \"*\"
    },
    \"extra\": {
        \"symfony\": {
            \"allow-contrib\": false,
            \"require\": \"5.3.*\"
        }
    }
}
  • 你为什么不升级你的php版本?
  • 谢谢你的回答,但我担心其他项目他不会工作
  • 您可以有多个 php 版本,只需在项目之间切换 :)

【解决方案1】:

您的 PHP 版本 7.3.5 不满足 laminas/laminas-code 的要求。

将系统上的 PHP 版本更新为 7.4 8.0 以解决 composer 错误。

或者,您可以“伪造” composer.json 中的当前 PHP 版本。

使用 config.platform 覆盖 composer 检测到的 PHP 版本:

{
  "config": {
    "platform": {
        "php": "7.4.0"
    }
  }
}

【讨论】: