如何列出Laravel项目中安装的所有composer模块和GitHub URL?

我正在构建某种分析软件。

如何在Laravel项目中找到已安装的composer / PHP模块的Github Urls?

我希望所有这些URL都不一样,而是在控制台中看起来像一个列表。

类似这样的东西:

{ "type": "vcs","url": "https://github.com/twigphp/Twig" },{ "type": "vcs","url": "https://github.com/sitepoint/rauth" },"url": "https://github.com/PHP-DI/PHP-DI" },"url": "https://github.com/nikic/FastRoute" },"url": "https://github.com/guzzle/guzzle" },"url": "https://github.com/Respect/Validation" },"url": "https://github.com/doctrine/annotations" },"url": "https://github.com/thephpleague/glide" },"url": "https://github.com/tamtamchik/simple-flash" },"url": "https://github.com/Seldaek/monolog" },"url": "https://github.com/cakephp/orm" },"url": "https://github.com/Bee-Lab/bowerphp" },"url": "https://github.com/markstory/mini-asset" },"url": "https://github.com/natxet/CssMin" },"url": "https://github.com/linkorb/jsmin-php" },"url": "https://github.com/consolidation-org/Robo" },"url": "https://github.com/symfony/var-dumper" },
nicklong465 回答:如何列出Laravel项目中安装的所有composer模块和GitHub URL?

composer info不会为您提供该信息。

最简单的方法是直接从composer.lock获取它。除了编写自己的解析器之外,您还可以使用jq之类的现成工具。

下载后,您可以编写如下表达式:

jq -c ".packages[]|{url:.source.url,type: .source.type}" composer.lock

这将过滤packages的{​​{1}}属性,并创建与您想要的输出非常相似的输出。例如:

composer.lock

这另一个表达式将创建一个对象数组,如您的示例中一样,它们已经用逗号分隔(但不太紧凑):

{"url":"https://github.com/api-platform/api-pack.git","type":"git"}
{"url":"https://github.com/api-platform/core.git","type":"git"}
{"url":"https://github.com/aws/aws-sdk-php.git","type":"git"}
{"url":"https://github.com/aws/aws-sdk-php-symfony.git","type":"git"}
{"url":"https://github.com/beberlei/DoctrineExtensions.git","type":"git"}

结果:

jq "[.packages[]|{url:.source.url,type: .source.type}]" composer.lock
本文链接:https://www.f2er.com/3125956.html

大家都在问