Composer 默认使用 zip 打包,可通过 composer.json 的 config 字段设置 archive-format 为 tar 等格式,结合 archive-compress 或命令行选项生成 tar.gz;也可在执行 archive 命令时用 --format 指定格式,但不支持全局配置。

Composer 默认打包项目时使用的是 zip 格式,但你可以通过配置 archive-format 来修改默认的压缩包格式。这个设置通常用于 composer archive 命令执行时生成的文件类型。
你可以在项目的 composer.json 文件中添加 config 字段来指定打包格式。支持的格式包括:zip 和 tar(也支持 tar.gz、tar.bz2 等,但需结合其他选项)。
示例:将默认打包格式设为 tar.gz
{
"config": {
"archive-format": "tar",
"archive-dir": "./dist"
}
}
注意:archive-format 设置为 tar 后,若你想生成压缩版本(如 .tar.gz),还需配合使用 archive-compress 选项或在命令行中指定。
如果不修改配置文件,也可以在执行 archive 命令时直接指定:
composer archive --format=zip —— 生成 zip 包composer archive --format=tar —— 生成 tar 包composer archive --format=tar --compress=gz —— 生成 .tar.gz目前 Composer 不支持通过 config 命令设置 archive-format 作为全局默认值。该配置只能写入具体项目的 composer.json 或通过自定义脚本封装命令实现统一行为。
如果你希望团队统一输出格式,建议在项目文档或 CI 脚本中明确打包命令。
基本上就这些。合理配置能让你的发布流程更顺畅。
以上就是Composer如何配置archive-format设置默认打包格式的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号