我使用Composer使用以下语法安装多个软件包:
{
"require": {
"aws/aws-sdk-php": "2.*",
"vimeo/vimeo-api" : "1.1.*",
"phpoffice/phpexcel": "dev-master"
}
}
以上工作正常,但现在我想通过composer添加tcpdf。我发现这段代码here但不确定如何与我当前的要求集成。我试过的一件事就是将它添加到最后,但我担心它会开始删除我当前的包。
{ "name": "tecnick.com/tcpdf",
"version": "6.2.11",
"homepage": "http://www.tcpdf.org/",
"type": "library",
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
"keywords": ["PDF","tcpdf","PDFD32000-2008","qrcode","datamatrix","pdf417","barcodes"],
"license": "LGPLv3",
"authors": [
{
"name": "Nicola Asuni",
"email": "info@tecnick.com",
"homepage": "http://nicolaasuni.tecnick.com"
}
],
"require": {
"php": ">=5.3.0"
},
"autoload": {
"classmap": [
"fonts",
"config",
"include",
"tcpdf.php",
"tcpdf_parser.php",
"tcpdf_import.php",
"tcpdf_barcodes_1d.php",
"tcpdf_barcodes_2d.php",
"include/tcpdf_colors.php",
"include/tcpdf_filters.php",
"include/tcpdf_font_data.php",
"include/tcpdf_fonts.php",
"include/tcpdf_images.php",
"include/tcpdf_static.php",
"include/barcodes/datamatrix.php",
"include/barcodes/pdf417.php",
"include/barcodes/qrcode.php"
]
}
答案 0 :(得分:12)
您可以从命令行中输入许多软件包,例如:
composer require barryvdh/laravel-debugbar barryvdh/laravel-snappy fideloper/proxy
根据你的作曲家规范,所有的包都是必需的。
答案 1 :(得分:4)
要将“tecnick.com/tcpdf”添加到现有composer.json
文件,请在包含它的目录内的命令行上运行:
composer require tecnick.com/tcpdf
您不必为这些事情手动编辑composer.json文件。
答案 2 :(得分:4)
事实上,您可以列出所有用空格隔开的软件包,如下所示:
composer require aws/aws-sdk-php vimeo/vimeo-api phpoffice/phpexcel
报价:
如果您不想以交互方式选择需求,则可以通过 他们执行命令
还考虑使用--update-with-all-dependencies
更新所有新安装软件包的依赖关系。
答案 3 :(得分:3)
如果有其他人来到这里并想知道如何添加"多个"软件包,只需运行多个CLI命令,方法是用分号终止它们,例如:
composer require drupal/pathauto;
composer require drupal/google_analytics;
composer require drupal/devel;
composer require drupal/linkit;
composer require drupal/editor_file;
N.B。这是一般解决方案,而不仅仅是作曲家。
答案 4 :(得分:0)
如果您想添加少量软件包,而不必在每个软件包之后都烦琐地等待作曲家进行更新,但是您不希望这样做:
...然后使用--no-update
开关使作曲家仅修改composer.json
文件,而无需搜索包。
您可以运行任意数量的任意数量的设备,使用CLI在途中执行其他操作,当您准备就绪时,只需单独执行composer-update
。
下面是为新项目添加一些Drupal模块的示例:
composer require 'drupal/field_permissions:^1.0' --no-update
composer require 'drupal/coffee:^1.0' --no-update
composer require 'drupal/token:^1.5' --no-update
composer require 'drupal/field_tools:^1.0' --no-update
composer require 'drupal/required_by_role:^1.0' --no-update
composer require 'drupal/devel:^2.1' --no-update
composer require 'drupal/config_ignore:^2.1' --no-update
composer require 'drupal/ga_login:^1.0' --no-update
composer require 'drupal/tfa:^1.0' --no-update
composer require 'drupal/spambot:^1.0' --no-update
composer require 'drupal/pathauto:^1.4' --no-update
composer require 'drupal/flag:^4.0' --no-update
composer require 'drupal/stringoverrides:1.x-dev' --no-update
composer require 'drupal/structure_sync:^1.16' --no-update
composer require 'drupal/masquerade:^2.0' --no-update
composer require 'drupal/metatag:^1.8' --no-update
composer require 'drupal/unique_field_ajax:^1.2' --no-update
composer require 'drupal/config_override_warn:^1.2' --no-update
composer require 'drupal/environment_indicator:^3.6' --no-update
composer require 'drupal/role_delegation:^1.0' --no-update
composer require 'drupal/seo_checklist:^4.1' --no-update
composer update
注意:如果您知道需要哪些模块并且仍要手动输入列表,只需手动编辑composer.json
-重复输入“ composer require”是没有意义的再次。
但是,上述方法对于像Drupal这样的站点非常方便,您可以在其中复制和粘贴包含分支,单个提交等复杂版本语法的预写命令。