Php 如何列出安装在Laravel项目中的所有composer模块和GitHub URL?
我在构建一种分析软件 如何在Laravel项目中找到已安装的composer/PHP模块的Github URL 我希望看到所有这些URL不是一个一个的,而是作为一个整体,可能是控制台中的列表 大概是这样的:Php 如何列出安装在Laravel项目中的所有composer模块和GitHub URL?,php,composer-php,Php,Composer Php,我在构建一种分析软件 如何在Laravel项目中找到已安装的composer/PHP模块的Github URL 我希望看到所有这些URL不是一个一个的,而是作为一个整体,可能是控制台中的列表 大概是这样的: {“类型”:“vcs”,“url”:https://github.com/twigphp/Twig" }, {“类型”:“vcs”,“url”:https://github.com/sitepoint/Rauth" }, {“类型”:“vcs”,“url”:https://github.co
{“类型”:“vcs”,“url”:https://github.com/twigphp/Twig" },
{“类型”:“vcs”,“url”:https://github.com/sitepoint/Rauth" },
{“类型”:“vcs”,“url”:https://github.com/PHP-DI/PHP-DI" },
{“类型”:“vcs”,“url”:https://github.com/nikic/FastRoute" },
{“类型”:“vcs”,“url”:https://github.com/guzzle/guzzle" },
{“类型”:“vcs”,“url”:https://github.com/Respect/Validation" },
{“类型”:“vcs”,“url”:https://github.com/doctrine/annotations" },
{“类型”:“vcs”,“url”:https://github.com/thephpleague/glide" },
{“类型”:“vcs”,“url”:https://github.com/tamtamchik/simple-flash" },
{“类型”:“vcs”,“url”:https://github.com/Seldaek/monolog" },
{“类型”:“vcs”,“url”:https://github.com/cakephp/orm" },
{“类型”:“vcs”,“url”:https://github.com/Bee-Lab/bowerphp" },
{“类型”:“vcs”,“url”:https://github.com/markstory/mini-asset" },
{“类型”:“vcs”,“url”:https://github.com/natxet/CssMin" },
{“类型”:“vcs”,“url”:https://github.com/linkorb/jsmin-php" },
{“类型”:“vcs”,“url”:https://github.com/consolidation-org/Robo" },
{“类型”:“vcs”,“url”:https://github.com/symfony/var-dumper" },
{“类型”:“vcs”,“url”:https://github.com/consolidation-org/Robo" },
作曲家信息
不会提供这些信息
最简单的方法是直接从composer.lock
获取它。不必编写自己的解析器,您可以使用现成的工具,如
下载后,您可以编写如下表达式:
jq-c.packages[]|{url:.source.url,type:.source.type}“composer.lock
这将过滤composer.lock
的packages
属性,并将创建与所需输出非常相似的输出。例如:
{“url”:https://github.com/api-platform/api-pack.git“,”类型“:“git”}
{“url”:https://github.com/api-platform/core.git“,”类型“:“git”}
{“url”:https://github.com/aws/aws-sdk-php.git“,”类型“:“git”}
{“url”:https://github.com/aws/aws-sdk-php-symfony.git“,”类型“:“git”}
{“url”:https://github.com/beberlei/DoctrineExtensions.git“,”类型“:“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"
}
[...]
]
不,最重要的是,我会得到模块的URL,不像
类型
条目。我不明白,模块的URL包含在这个答案的所有输出中。