mvorisek
mvorisek

Reputation: 3418

Composer: Get package info without installation

Can I use composer to get package info, i.e. data from composer.json and composer.lock from any package without installing it? Is is possible from the composer CLI?

Upvotes: 1

Views: 1302

Answers (2)

D Malan
D Malan

Reputation: 11414

You can use composer show <vendor>/<package> <version> to show information about a package. You can use the -a option for uninstalled packages. It's not in the exact same format as composer.json, but it displays almost the same contents.

For example, composer show barryvdh/laravel-debugbar -a:


name     : barryvdh/laravel-debugbar
descrip. : PHP Debugbar integration for Laravel
keywords : debug, profiler, laravel, debugbar, webprofiler
versions : dev-master, 3.2.x-dev, v3.2.8, v3.2.7, v3.2.6, v3.2.5, v3.2.4, v3.2.3, v3.2.2, v3.2.1, v3.2.0, v3.1.5, v3.1.4, v3.1.3, v3.1.2, v3.1.1, v3.1.0, v3.0.1, v3.0.0, 2.4.x-dev, v2.4.3, v2.4.2, v2.4.1, v2.4.0, v2.3.2, v2.3.1, v2.3.0, V2.2.3, v2.2.2, v2.2.1, v2.2.0, v2.1.4, v2.1.3, v2.1.2, v2.1.1, v2.1.0, v2.0.6, v2.0.5, v2.0.4, v2.0.3, v2.0.2, v2.0.1, v2.0.0, 1.8.x-dev, v1.8.9, v1.8.8, v1.8.7, v1.8.6, v1.8.5, v1.8.4, v1.8.3, v1.8.2, v1.8.1, v1.8.0, v1.7.7, v1.7.6, v1.7.5, v1.7.4, v1.7.3, v1.7.2, v1.7.1, v1.7.0, v1.6.8, v1.6.7, v1.6.6, v1.6.5, v1.6.4, v1.6.3, v1.6.2, v1.6.1, v1.6.0, v1.5.5, v1.5.4, v1.5.3, v1.5.2, v1.5.1, v1.5.0, v1.4.3, v1.4.2, v1.4.1, v1.4, v1.3.1, v1.3, v1.2.3, v1.2.2, v1.2.1, v1.2, v1.1.5, v1.1.4, v1.1.3, v1.1.2, v1.1.1, v1.1, v1.0.4, v1.0.3, v1.0.2, v1.0.1, v1.0, v0.3.2, v0.3.1, v0.3, v0.2, v0.1.0, dev-revert-463-master, dev-revert-353-1.8, dev-revert-350-fix_query_logging_is_off, dev-revert-339-dha0stw-patch-disableVendors, dev-reset, dev-telescope-link, dev-feat-multiauth, dev-feat-csp
type     : library
license  : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
source   : [git] https://github.com/barryvdh/laravel-debugbar.git 35638e4f5e714a12dec5ca062e68c625c1309c1c
dist     : [zip] https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/35638e4f5e714a12dec5ca062e68c625c1309c1c 35638e4f5e714a12dec5ca062e68c625c1309c1c
names    : barryvdh/laravel-debugbar

autoload
psr-4
Barryvdh\Debugbar\ => src/
files

requires
php >=7.0
illuminate/routing ^5.5|^6
illuminate/session ^5.5|^6
illuminate/support ^5.5|^6
symfony/debug ^3|^4|^5
symfony/finder ^3|^4|^5
maximebf/debugbar ^1.15

requires (dev)
laravel/framework 5.5.x

composer show supports a --format JSON argument, but it doesn't seem to work. There is a PR in the works that would hopefully allow you to get the JSON version.

Upvotes: 4

mvorisek
mvorisek

Reputation: 3418

It seems that it is not possible currently from the composer CLI (as of Jan 2020), but data can be queried from the Packagist API:

https://packagist.org/apidoc#get-package-data

Upvotes: 0

Related Questions