有没有办法显示来自 Composer 存储库的消息?
Is there a way to show a message from a Composer repository?
如果我有一个 Composer repository(不是 Composer 包或 Git 存储库)列出包并且人们可以将其包含在 composer.json
下 repositories
部分,是否可以显示来自存储库所有者的消息?
因此,例如,如果我在 example.com/packages.json
有一个存储库并且用户将以下内容添加到他们项目的 composer.json
:
"repositories": [
{
"type": "composer",
"url": "https://example.com"
}
如何向我的 packages.json
添加内容 "Hello, this is the example.com repository"?
确实有办法
您可以决定是否要显示 "info" 或 "warning" 消息,然后将 packages.json
中的 "info" 或 "warning" 设置为您希望显示的消息。
然后您还需要将 "info-versions" 或 "warning-versions" 设置为要为其显示消息的 Composer 版本。如果你想为所有版本的 Composer 显示它,你可以使用 >=0.0.0
.
如果您有兴趣,请查看 Composer 调用函数的源代码 outputWarnings to display the messages is here。
每次您 运行 Composer 命令需要从存储库中获取包时都会显示消息,包括 composer install
、composer update
和 composer require
.
这里是一个示例 packages.json
文件,它将同时显示警告和信息消息:
{
"packages": {},
"warning": "Warning message",
"warning-versions": ">=0.0.0",
"info": "Info message",
"info-versions": ">=0.0.0"
}
我已将此文件添加到 gist。您可以通过将其作为存储库添加到您的 composer.json
文件然后 运行ning composer install
:
来尝试
"repositories": [
{
"type": "composer",
"url": "https://gist.githubusercontent.com/delenamalan/3c0d998a316031af8f0f9c0165eacc28/raw/491d2716bb8d36fea562633f2384340f560aceb6"
}
],
这是一个示例输出:
$ composer install
Loading composer repositories with package information
Warning from https://gist.githubusercontent.com/delenamalan/3c0d998a316031af8f0f9c0165eacc28/raw/491d2716bb8d36fea562633f2384340f560aceb6:
Warning message
Info from https://gist.githubusercontent.com/delenamalan/3c0d998a316031af8f0f9c0165eacc28/raw/491d2716bb8d36fea562633f2384340f560aceb6:
Info message
Updating dependencies (including require-dev)
如果我有一个 Composer repository(不是 Composer 包或 Git 存储库)列出包并且人们可以将其包含在 composer.json
下 repositories
部分,是否可以显示来自存储库所有者的消息?
因此,例如,如果我在 example.com/packages.json
有一个存储库并且用户将以下内容添加到他们项目的 composer.json
:
"repositories": [
{
"type": "composer",
"url": "https://example.com"
}
如何向我的 packages.json
添加内容 "Hello, this is the example.com repository"?
确实有办法
您可以决定是否要显示 "info" 或 "warning" 消息,然后将 packages.json
中的 "info" 或 "warning" 设置为您希望显示的消息。
然后您还需要将 "info-versions" 或 "warning-versions" 设置为要为其显示消息的 Composer 版本。如果你想为所有版本的 Composer 显示它,你可以使用 >=0.0.0
.
如果您有兴趣,请查看 Composer 调用函数的源代码 outputWarnings to display the messages is here。
每次您 运行 Composer 命令需要从存储库中获取包时都会显示消息,包括 composer install
、composer update
和 composer require
.
这里是一个示例 packages.json
文件,它将同时显示警告和信息消息:
{
"packages": {},
"warning": "Warning message",
"warning-versions": ">=0.0.0",
"info": "Info message",
"info-versions": ">=0.0.0"
}
我已将此文件添加到 gist。您可以通过将其作为存储库添加到您的 composer.json
文件然后 运行ning composer install
:
"repositories": [
{
"type": "composer",
"url": "https://gist.githubusercontent.com/delenamalan/3c0d998a316031af8f0f9c0165eacc28/raw/491d2716bb8d36fea562633f2384340f560aceb6"
}
],
这是一个示例输出:
$ composer install
Loading composer repositories with package information
Warning from https://gist.githubusercontent.com/delenamalan/3c0d998a316031af8f0f9c0165eacc28/raw/491d2716bb8d36fea562633f2384340f560aceb6:
Warning message
Info from https://gist.githubusercontent.com/delenamalan/3c0d998a316031af8f0f9c0165eacc28/raw/491d2716bb8d36fea562633f2384340f560aceb6:
Info message
Updating dependencies (including require-dev)