Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get stats from packagist for all WP related packages
#!/usr/bin/env php
<?php
$plugins = file_get_contents( 'https://packagist.org/packages/list.json?type=wordpress-plugin' );
$muplugins = file_get_contents( 'https://packagist.org/packages/list.json?type=wordpress-muplugin' );
$dropins = file_get_contents( 'https://packagist.org/packages/list.json?type=wordpress-dropin' );
$themes = file_get_contents( 'https://packagist.org/packages/list.json?type=wordpress-theme' );
$plugins_json = json_decode( $plugins, true )['packageNames'];
$muplugins_json = json_decode( $muplugins, true )['packageNames'];
$dropins_json = json_decode( $dropins, true )['packageNames'];
$themes_json = json_decode( $themes, true )['packageNames'];
echo sprintf(
"Plugins: %d\nMU Plugins: %d\nDropins: %d\nThemes: %d\n\n",
count( $plugins_json ),
count( $muplugins_json ),
count( $dropins_json ),
count( $themes_json )
);
$all = array_merge(
$plugins_json,
$muplugins_json,
$dropins_json,
$themes_json,
// Add popular WP installer composer plugins.
[ 'johnpbloch/wordpress', 'fancyguy/webroot-installer' ]
);
$total = 0;
$monthly = 0;
$daily = 0;
foreach ( $all as $package ) {
$package_data = file_get_contents( "https://packagist.org/packages/{$package}.json" );
$package_json = json_decode( $package_data, true );
$total += $package_json['package']['downloads']['total'];
$monthly += $package_json['package']['downloads']['monthly'];
$daily += $package_json['package']['downloads']['daily'];
}
echo sprintf(
"Downloads:\nTotal: %s\nMonthly: %s\nDaily: %s\n",
number_format( $total ),
number_format( $monthly ),
number_format( $daily )
);
@roborourke

This comment has been minimized.

Copy link
Owner Author

@roborourke roborourke commented Jan 23, 2020

Output on 23rd Jan 2020:

Packages:
Plugins: 1979
MU Plugins: 355
Dropins: 15
Themes: 245

Downloads:
Total: 9,881,979
Monthly: 252,732
Daily: 15,312
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.