如何列出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" },
{ "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" },
伊维

composer info 不会给您这些信息。

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

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

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

这将过滤的packages属性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

结果:

[
  {
    "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"
  }
[...]
]

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章