Skip to content

Instantly share code, notes, and snippets.

@roborourke
Last active February 20, 2020 11:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roborourke/bc2a677e46638f1e9df8923cc88622e3 to your computer and use it in GitHub Desktop.
Save roborourke/bc2a677e46638f1e9df8923cc88622e3 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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