dst8922 2015-12-10 23:16
浏览 357
已采纳

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

So today I tried to install bootstrap with the composer via composer.json. I added twbs/bootstrap in my require list at the composer.json file in my project map and runned the command

$ composer update

It was succesfully downloaded and with a few adjustments to my code and command line I can use it now in my base:html.twig file.

Unfortunately, the composer updated also my version of symfony from 2.7 to 2.8. Is there any option that I update/download bootstrap without updating my version number of Symfony, doctrine etc with the composer? My code of 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"
    }
}
}
  • 写回答

2条回答 默认 最新

  • doushishi6513 2015-12-11 10:00
    关注

    You can require the library:

    $composer require twbs/bootstrap
    

    This will put the library in a compatible version with the libraries you have.

    If you also don't want to update Symfony in the future, you can add an extra version to the string:

    "require": {
      "symfony/symfony": "~2.7.0@beta",
    },
    

    This will make composer understand you don't want to upgrade to 2.8 or highter versions.

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • dptj13337 2015-12-11 06:47
    关注

    If you only want to install or update one dependency, you can whitelist them:

    php composer.phar update twbs/bootstrap
    

    More info in the official doc

    Another way is with the require command:

    The require command adds new packages to the composer.json file from the current directory. If no file exists one will be created on the fly.

    php composer.phar require vendor/package:2.*
    

    Hope this help

    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 android百度地图SDK海量点显示标题
  • ¥15 windows导入environment.yml运行conda env create -f environment_win.yml命令报错
  • ¥15 这段代码可以正常运行,打包后无法执行,在执行for内容之前一直不断弹窗,请修改调整
  • ¥15 C语言判断有向图是否存在环路
  • ¥15 请问4.11到4.18以及4.27和4.29公式的具体推导过程是怎样的呢
  • ¥20 将resnet50中的卷积替换微ODConv动态卷积
  • ¥15 通过文本框输入商品信息点击按钮将商品信息列举出来点击加入购物车商品信息添加到表单中
  • ¥100 这是什么压缩算法?如何解压?
  • ¥20 upload上传实验报错500,如何解决?(操作系统-windows)
  • ¥15 谁知道 ShaderGraph 那个节点可以接入 Particle System -> Custom Data