首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何列出在Laravel项目中安装的所有composer模块和GitHub URL?

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

Stack Overflow用户
提问于 2019-11-11 15:21:15
回答 1查看 132关注 0票数 3

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

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

我希望看到所有这些URL,而不是一个一个,但作为一个整体,可能在控制台中的列表。

如下所示:

代码语言:javascript
复制
{ "type": "vcs", "url": "https://github.com/twigphp/Twig" },
{ "type": "vcs", "url": "https://github.com/sitepoint/Rauth" },
{ "type": "vcs", "url": "https://github.com/PHP-DI/PHP-DI" },
{ "type": "vcs", "url": "https://github.com/nikic/FastRoute" },
{ "type": "vcs", "url": "https://github.com/guzzle/guzzle" },
{ "type": "vcs", "url": "https://github.com/Respect/Validation" },
{ "type": "vcs", "url": "https://github.com/doctrine/annotations" },
{ "type": "vcs", "url": "https://github.com/thephpleague/glide" },
{ "type": "vcs", "url": "https://github.com/tamtamchik/simple-flash" },
{ "type": "vcs", "url": "https://github.com/Seldaek/monolog" },
{ "type": "vcs", "url": "https://github.com/cakephp/orm" },
{ "type": "vcs", "url": "https://github.com/Bee-Lab/bowerphp" },
{ "type": "vcs", "url": "https://github.com/markstory/mini-asset" },
{ "type": "vcs", "url": "https://github.com/natxet/CssMin" },
{ "type": "vcs", "url": "https://github.com/linkorb/jsmin-php" },
{ "type": "vcs", "url": "https://github.com/consolidation-org/Robo" },
{ "type": "vcs", "url": "https://github.com/symfony/var-dumper" },
{ "type": "vcs", "url": "https://github.com/consolidation-org/Robo" },
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-11-11 17:17:13

composer info不会给你这些信息的

最简单的方法是直接从composer.lock获取它。您可以使用像jq这样的现成工具,而不是编写自己的解析器。

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

代码语言:javascript
复制
jq -c ".packages[]|{url:.source.url, type: .source.type}" composer.lock

这将过滤composer.lockpackages属性,并将创建与您想要的输出非常相似的输出。例如:

代码语言:javascript
复制
{"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"}

另一个表达式将创建一个对象数组,在示例中已经用逗号分隔(但不是很紧凑):

代码语言:javascript
复制
jq "[.packages[]|{url:.source.url, type: .source.type}]" composer.lock

结果:

代码语言:javascript
复制
[
  {
    "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"
  }
[...]
]
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58797063

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档