Composer/Laravel:如何添加/更新特定包

问题描述 投票:0回答:4

如何使用 Composer 添加/更新特定包?我也在使用最新的 Laravel,不确定它是否重要,但任何可以帮助确定答案的东西。

我还尝试了我发现的旧 Stackoverflow 帖子中的以下内容,但它对我不起作用。它将包附加到composer.json,然后继续更新所有内容。链接如下:如何使用 Composer 更新单个库?

这是我尝试添加到我的项目中的包:https://github.com/barryvdh/laravel-dompdf

非常感谢您的时间和帮助!

编辑:


要求和更新不起作用,他们也会更新所有内容。是否有可能我运行的命令不正确?说到作曲家,我还是一头雾水:S

$ composer require barryvdh/laravel-dompdf
lease provide a version constraint for the barryvdh/laravel-dompdf requirement: *
/composer.json has been updated
oading composer repositories with package information
pdating dependencies (including require-dev)
 - Removing orchestra/testbench (v2.1.1)
 - Removing symfony/security (v2.4.3)
 - Removing symfony/translation (v2.4.3)
 - Installing symfony/translation (v2.4.6)
   Loading from cache

 - Removing symfony/http-foundation (v2.4.3)
 - Installing symfony/http-foundation (v2.4.6)
   Loading from cache

 - Removing symfony/event-dispatcher (v2.4.3)
 - Installing symfony/event-dispatcher (v2.5.0)
   Loading from cache

 - Removing symfony/debug (v2.4.3)
 - Installing symfony/debug (v2.4.6)
   Loading from cache

 - Removing symfony/http-kernel (v2.4.3)
 - Installing symfony/http-kernel (v2.4.6)
   Loading from cache

 - Removing symfony/routing (v2.4.3)
 - Installing symfony/routing (v2.4.6)
   Loading from cache

 - Removing symfony/process (v2.4.3)
 - Installing symfony/process (v2.4.6)
   Loading from cache

 - Removing symfony/finder (v2.4.3)
 - Installing symfony/finder (v2.4.6)
   Loading from cache

 - Removing symfony/dom-crawler (v2.4.3)
 - Installing symfony/dom-crawler (v2.4.6)
   Loading from cache

 - Removing symfony/css-selector (v2.4.3)
 - Installing symfony/css-selector (v2.4.6)
   Loading from cache

 - Removing symfony/console (v2.4.3)
 - Installing symfony/console (v2.4.6)
   Loading from cache

 - Removing symfony/browser-kit (v2.4.3)
 - Installing symfony/browser-kit (v2.4.6)
   Loading from cache

 - Removing swiftmailer/swiftmailer (v5.1.0)
 - Installing swiftmailer/swiftmailer (v5.2.0)
   Loading from cache

 - Removing stack/builder (v1.0.1)
 - Installing stack/builder (v1.0.2)
   Loading from cache

  - Removing patchwork/utf8 (v1.1.21)
  - Installing patchwork/utf8 (v1.1.23)
    Loading from cache

  - Removing nesbot/carbon (1.8.0)
  - Installing nesbot/carbon (1.9.0)
    Loading from cache

  - Removing monolog/monolog (1.9.0)
  - Installing monolog/monolog (1.10.0)
    Loading from cache

  - Removing symfony/filesystem (v2.4.3)
  - Installing symfony/filesystem (v2.5.0)
    Loading from cache

  - Installing symfony/security-core (v2.4.6)
    Loading from cache

  - Removing laravel/framework (v4.1.28)
  - Installing laravel/framework (v4.1.30)
    Loading from cache

  - Removing chumper/datatable (2.2.2)
  - Installing chumper/datatable (2.3)
    Loading from cache

  - Removing ivaynberg/select2 (3.4.6)
  - Installing ivaynberg/select2 (3.4.8)
    Loading from cache

  - Installing phenx/php-font-lib (0.2.2)
    Loading from cache

  - Installing dompdf/dompdf (v0.6.1)
    Loading from cache

  - Installing barryvdh/laravel-dompdf (v0.3.1)
    Loading from cache

symfony/security-core suggests installing symfony/validator (For using the user password constraint)
symfony/security-core suggests installing symfony/expression-language (For using the expression voter)
Generating autoload files
Compiling component files
Generating optimized class loader
php laravel laravel-4 composer-php
4个回答
37
投票

我尝试了以下方法,它似乎对我有用。

您必须首先将

barryvdh/laravel-dompdf
添加到
composer.json
文件中。然后执行以下操作:

 composer update barryvdh/laravel-dompdf --lock

9
投票

这里

composer update barryvdh/laravel-dompdf

作曲家文档


1
投票

上述解决方案对我不起作用,但是如果有人仍然面临这个问题

composer require <package> --no-update

这在添加包时对我有用


0
投票

composer update <package> --lock
仍然安装composer.json中的所有其他包。

我的解决方法是将所需的包安装在单独的目录中,并用新安装的文件夹替换现有文件夹。然后我将更改composer.json中的版本以匹配已安装的版本。

不太确定是否需要更改composer.lock,对此有什么建议吗?

© www.soinside.com 2019 - 2024. All rights reserved.