Symfony 3.2:twig/twig v2.0.0 需要 php ^7.0
Posted
技术标签:
【中文标题】Symfony 3.2:twig/twig v2.0.0 需要 php ^7.0【英文标题】:Symfony 3.2: twig/twig v2.0.0 requires php ^7.0 【发布时间】:2017-07-14 01:11:48 【问题描述】:我只是想在一台装有 php 5.6 的服务器上安装我的 Symfony 3.2 应用程序,composer install
告诉我 twig/twig v2.0.0 requires php ^7.0 -> your PHP version (5.6.22) does not satisfy that requirement.
如何更改应用中使用的 Twig 版本?据我了解,Symfony 使用 twig-bundle (https://packagist.org/packages/symfony/twig-bundle)。
我需要在较低版本中添加 symfony/twig-bundle(哪个?)还是需要将 twig/twig v1.31.0 添加到我的 composer.json 要求部分?
更新:
我的composer.json
:
"name": "...",
"license": "proprietary",
"type": "project",
"autoload":
"psr-4":
"": "src/"
,
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
,
"autoload-dev":
"psr-4":
"Tests\\": "tests/"
,
"require":
"php": ">=5.5.9",
"symfony/symfony": "3.2.*",
"twig/twig": "1.31.*",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"symfony/swiftmailer-bundle": "^2.3",
"symfony/monolog-bundle": "^3.0",
"symfony/polyfill-apcu": "^1.0",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "^2.0",
"javiereguiluz/easyadmin-bundle": "^1.16",
"doctrine/doctrine-fixtures-bundle": "^2.3",
"symfony/dom-crawler": "^3.2"
,
"require-dev":
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.0"
,
"scripts":
"symfony-scripts": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-install-cmd": [
"@symfony-scripts"
],
"post-update-cmd": [
"@symfony-scripts"
]
,
"extra":
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"incenteev-parameters":
"file": "app/config/parameters.yml"
,
"branch-alias": null
我的命令:
【问题讨论】:
你能把你的composer.json
文件贴在这里吗?
@TomaszMadeyski 我做到了:)
【参考方案1】:
您可以使用 Twig 1.x:。在您的 composer.json
中添加/更改它:
"require":
"symfony/symfony": "v3.2.*",
"twig/twig": "1.31.*"
然后运行composer update
。如果您想知道install
和update
之间的区别是什么,请阅读this answer。
【讨论】:
感谢您的回答斯蒂芬。我添加了 twig 包,但使用 composer install 它仍然尝试安装 v2.0.0。也许我需要以某种方式更新 composer.lock ?我将发布我的 composer.json 和命令结果作为我的问题的更新。 更改composer.json
后,您需要运行composer update
(而不是install
)
啊,是的,当然!谢谢,你的回答解决了我的问题:)以上是关于Symfony 3.2:twig/twig v2.0.0 需要 php ^7.0的主要内容,如果未能解决你的问题,请参考以下文章