Skip to content

Instantly share code, notes, and snippets.

@soukicz
Created November 28, 2015 14:23
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 soukicz/b08d116563c3247c5337 to your computer and use it in GitHub Desktop.
Save soukicz/b08d116563c3247c5337 to your computer and use it in GitHub Desktop.
Find composer updates without version constraints
<?php
require_once __DIR__ . '/vendor/autoload.php';
$lock = json_decode(file_get_contents(__DIR__ . '/composer.lock'));
$json = json_decode(file_get_contents(__DIR__ . '/composer.json'), true)['require'];
$client = new \GuzzleHttp\Client();
foreach ($lock->packages as $package) {
$current = json_decode($client->get('https://packagist.org/packages/' . $package->name . '.json')->getBody(), true)['package']['versions'];
foreach ($current as $version => $data) {
if(preg_match('~^v?[0-9.]+$~', $version)) {
if($version > $package->version) {
echo $package->name . ": $version > " . $package->version . (isset($json[$package->name]) ?: '' . ' (dependency)') . "\n";
}
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment