所以今天我尝试通过composer.json与composer一起安装bootstrap。我在项目地图中的composer.json文件的需求列表中添加了twbs / bootstrap并运行命令
$ composer update
它已成功下载并对我的代码和命令行进行了一些调整,我现在可以在我的基础:html.twig文件中使用它。
不幸的是,作曲家还将我的symfony版本从2.7更新到2.8。有没有更新/下载bootstrap的选项而不用作曲家更新我的Symfony,doctrine等版本号? 我的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"
}
}
}
答案 0 :(得分:3)
您可以要求图书馆:
$composer require twbs/bootstrap
这将使库与您拥有的库兼容。
如果您以后也不想更新Symfony,可以在字符串中添加额外的版本:
"require": {
"symfony/symfony": "~2.7.0@beta",
},
这将使作曲家明白你不想升级到2.8或更高版本。
来源:https://getcomposer.org/doc/articles/versions.md#next-significant-release-operators
答案 1 :(得分:1)
如果您只想安装或更新一个依赖项,可以将它们列入白名单:
php composer.phar update twbs/bootstrap
中的更多信息
另一种方法是使用require命令:
require命令将新包添加到composer.json文件中 当前目录。如果不存在文件,则会在文件上创建 飞。
php composer.phar require vendor/package:2.*
希望这个帮助