gpt4 book ai didi

php - 使用 composer 安装库而不更新 composer.json 上当前库的版本

转载 作者:行者123 更新时间:2023-12-03 23:23:37 25 4
gpt4 key购买 nike

所以今天我尝试通过composer.json用composer安装 Bootstrap 。我在项目映射的 composer.json 文件的需要列表中添加了 twbs/bootstrap 并运行了命令

$ composer update

它已成功下载,并且对我的代码和命令行进行了一些调整,我现在可以在我的 base:html.twig 文件中使用它。

不幸的是, Composer 也将我的 symfony 版本从 2.7 更新到了 2.8。有没有什么选项可以让我更新/下载 Bootstrap 而不用 Composer 更新我的 Symfony、学说等的版本号?
我的composer.json代码:
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-4": { "": "src/", "SymfonyStandard\\": "app/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "~2.7@beta",
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
"doctrine/dbal": "<2.5",
"doctrine/doctrine-bundle": "~1.4",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0,>=3.0.12",
"sensio/framework-extra-bundle": "~3.0,>=3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/user-bundle": "~1.3",
"twbs/bootstrap": "3.2.*",
"components/jquery": "1.9.*"
},
"require-dev": {
"sensio/generator-bundle": "~2.3"
},
"scripts": {
"post-root-package-install": [
"SymfonyStandard\\Composer::hookRootPackageInstall"
],
"post-install-cmd": [
"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::removeSymfonyStandardFiles",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-update-cmd": [
"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::removeSymfonyStandardFiles",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.7-dev"
}
}
}

最佳答案

您可以要求该库:

$composer require twbs/bootstrap

这会将库置于与您拥有的库兼容的版本中。

如果你以后也不想更新 Symfony,你可以在字符串中添加一个额外的版本:
"require": {
"symfony/symfony": "~2.7.0@beta",
},

这将使 Composer 明白您不想升级到 2.8 或更高版本。

来源: https://getcomposer.org/doc/articles/versions.md#next-significant-release-operators

关于php - 使用 composer 安装库而不更新 composer.json 上当前库的版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34213529/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com