Skip to content

Instantly share code, notes, and snippets.

@PHLAK
Last active December 15, 2015 10:49
Show Gist options
  • Save PHLAK/5249009 to your computer and use it in GitHub Desktop.
Save PHLAK/5249009 to your computer and use it in GitHub Desktop.
PHP-CLI script to output a list of repositories (one per line) belonging to the user(s) specified.
#!/usr/bin/php -q
<?php
// Disable errors
error_reporting(0);
foreach ($argv as $user) {
if ($user !== $argv[0]) {
// Fetch user repositories from GitHub
$apiResults = file_get_contents('https://api.github.com/users/' . $user . '/repos');
if ($apiResults) {
// Decode the json object
$dataObject = json_decode($apiResults);
// Echo all repo URLs
foreach ($dataObject as $repo) {
echo $user . ";" . $repo->name . ";" . $repo->git_url . PHP_EOL;
}
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment