Skip to content

Instantly share code, notes, and snippets.

@alexander-schranz
Created December 16, 2022 15:55
Show Gist options
  • Save alexander-schranz/c9017ea31bf2b789cc366f4503916639 to your computer and use it in GitHub Desktop.
Save alexander-schranz/c9017ea31bf2b789cc366f4503916639 to your computer and use it in GitHub Desktop.
Get Composer Vendor Package Version date
<?php
// requires `rm -rf vendor && composer install --prefer-source` as it works via git tag
$dir = new DirectoryIterator(__DIR__ . "/vendor");
$list = [];
$biggestLength = 0;
foreach ($dir as $fileinfo) {
if (in_array($fileinfo->getFilename(), [".", ".."])) {
continue;
}
if (! $fileinfo->isDir()) {
continue;
}
$vendorDir = new DirectoryIterator($fileinfo->getPathname());
$vendorName = $fileinfo->getFilename();
foreach ($vendorDir as $fileinfo) {
if (in_array($fileinfo->getFilename(), [".", ".."])) {
continue;
}
if (! $fileinfo->isDir()) {
continue;
}
$packageDir = new DirectoryIterator($fileinfo->getPathname());
$packageName = $fileinfo->getFilename();
foreach ($packageDir as $fileinfo) {
if (! $fileinfo->isDir()) {
continue;
}
if (in_array($fileinfo->getFilename(), [".", ".."])) {
continue;
}
if (".git" !== $fileinfo->getFilename()) {
continue;
}
chdir(dirname($fileinfo->getPathname()));
exec("git show --summary", $gitShow);
$date = '';
foreach ($gitShow as $gitShowLine) {
if (str_starts_with($gitShowLine, "Date:")) {
$date = new DateTime(trim(substr($gitShowLine, 5, -1)));
}
}
$dateString = "";
$name = $vendorName . "/" . $packageName;
if ($date) {
$dateString = $date->format("Y-m-d H:i:s");
}
$list[$dateString . "_" . $name] = [
"name" => $name,
"date" => $dateString,
];
if ($biggestLength < strlen($name)) {
$biggestLength = strlen($name);
}
}
}
}
ksort($list);
$list = array_reverse($list);
foreach ($list as $package) {
echo str_pad($package["name"], $biggestLength + 2);
echo $package["date"];
echo PHP_EOL;
}
# requires `rm -rf vendor && composer install --prefer-source` as it works via git tag
php -r '$dir = new DirectoryIterator(__DIR__ . "/vendor"); $list = []; $biggestLength = 0; foreach ($dir as $fileinfo) { if (in_array($fileinfo->getFilename(), [".", ".."])) { continue;} if (! $fileinfo->isDir()) { continue; } $vendorDir = new DirectoryIterator($fileinfo->getPathname()); $vendorName = $fileinfo->getFilename(); foreach ($vendorDir as $fileinfo) { if (in_array($fileinfo->getFilename(), [".", ".."])) { continue; } if (! $fileinfo->isDir()) { continue; } $packageDir = new DirectoryIterator($fileinfo->getPathname()); $packageName = $fileinfo->getFilename(); foreach ($packageDir as $fileinfo) { if (! $fileinfo->isDir()) { continue; } if (in_array($fileinfo->getFilename(), [".", ".."])) { continue; } if (".git" !== $fileinfo->getFilename()) { continue; } chdir(dirname($fileinfo->getPathname())); exec("git show --summary", $gitShow); $date = ""; foreach ($gitShow as $gitShowLine) { if (str_starts_with($gitShowLine, "Date:")) { $date = new DateTime(trim(substr($gitShowLine, 5, -1))); } } $dateString = ""; $name = $vendorName . "/" . $packageName; if ($date) { $dateString = $date->format("Y-m-d H:i:s"); } $list[$dateString . "_" . $name] = [ "name" => $name, "date" => $dateString,]; if ($biggestLength < strlen($name)) { $biggestLength = strlen($name); } } } } ksort($list); $list = array_reverse($list); foreach ($list as $package) { echo str_pad($package["name"], $biggestLength + 2); echo $package["date"]; echo PHP_EOL;}'
phpstan/phpdoc-parser 2022-12-16 07:42:48
sulu/sulu 2022-12-15 11:29:04
doctrine/annotations 2022-12-12 13:46:12
laminas/laminas-code 2022-12-08 03:08:23
doctrine/doctrine-bundle 2022-12-07 13:07:11
ezimuel/ringphp 2022-12-07 12:28:53
excelwebzone/recaptcha-bundle 2022-12-02 06:58:24
friendsofsymfony/http-cache-bundle 2022-12-01 12:11:16
friendsofsymfony/http-cache 2022-12-01 12:05:52
symfony/psr-http-message-bridge 2022-11-28 23:46:34
symfony/http-kernel 2022-11-28 19:20:59
sentry/sentry-symfony 2022-11-28 13:37:44
symfony/mime 2022-11-28 13:27:40
symfony/form 2022-11-28 13:27:40
symfony/doctrine-bridge 2022-11-28 13:27:40
symfony/yaml 2022-11-25 19:59:16
symfony/framework-bundle 2022-11-25 19:59:16
symfony/console 2022-11-25 19:59:16
stella-maris/clock 2022-11-25 17:15:06
psr/clock 2022-11-25 15:36:26
symfony/translation-contracts 2022-11-25 11:21:52
symfony/deprecation-contracts 2022-11-25 11:21:52
symfony/cache-contracts 2022-11-25 11:21:52
symfony/property-info 2022-11-25 08:34:52
symfony/dependency-injection 2022-11-25 08:34:52
sentry/sentry 2022-11-22 10:57:08
doctrine/orm 2022-11-20 19:53:31
phpcr/phpcr-utils 2022-11-20 11:40:46
imagine/imagine 2022-11-16 14:09:11
symfony/messenger 2022-11-14 11:13:26
symfony/http-client 2022-11-14 11:13:26
symfony/cache 2022-11-14 11:13:26
handcraftedinthealps/sulu-resource-bundle 2022-11-07 14:42:36
symfony/http-foundation 2022-11-07 09:07:30
gedmo/doctrine-extensions 2022-11-06 15:11:57
ramsey/uuid 2022-11-05 18:03:38
symfony/twig-bridge 2022-11-04 08:40:42
symfony/mailer 2022-11-04 08:40:42
symfony/polyfill-php81 2022-11-03 14:41:12
symfony/polyfill-mbstring 2022-11-03 14:41:12
symfony/polyfill-intl-normalizer 2022-11-03 14:41:12
symfony/polyfill-intl-idn 2022-11-03 14:41:12
symfony/polyfill-intl-icu 2022-11-03 14:41:12
symfony/polyfill-intl-grapheme 2022-11-03 14:41:12
symfony/validator 2022-10-28 18:23:08
symfony/property-access 2022-10-28 18:23:08
symfony/lock 2022-10-28 18:23:08
symfony/error-handler 2022-10-28 18:23:08
symfony/dom-crawler 2022-10-28 18:23:08
massive/search-bundle 2022-10-28 13:08:19
handcraftedinthealps/elasticsearch-bundle 2022-10-27 12:39:52
guzzlehttp/psr7 2022-10-26 15:07:24
ezimuel/guzzlestreams 2022-10-24 14:58:50
doctrine/dbal 2022-10-24 09:26:18
symfony/security-http 2022-10-23 12:33:34
symfony/security-core 2022-10-23 12:33:34
symfony/intl 2022-10-23 12:33:34
sulu/web-twig 2022-10-20 16:17:17
doctrine/inflector 2022-10-20 11:10:12
sulu/redirect-bundle 2022-10-19 17:50:55
symfony/routing 2022-10-18 15:12:43
symfony/webpack-encore-bundle 2022-10-18 11:21:06
intosite/advertisement-bundle 2022-10-18 11:05:37
friendsofphp/proxy-manager-lts 2022-10-17 21:21:23
matomo/device-detector 2022-10-14 13:08:35
doctrine/persistence 2022-10-13 09:17:40
doctrine/event-manager 2022-10-12 22:51:15
symfony/serializer 2022-10-12 07:10:31
symfony/string 2022-10-10 11:34:31
doctrine/common 2022-10-09 13:47:59
symfony/var-dumper 2022-10-07 10:04:03
symfony/translation 2022-10-07 10:04:03
symfony/expression-language 2022-10-07 10:04:03
elasticsearch/elasticsearch 2022-09-30 14:28:55
stof/doctrine-extensions-bundle 2022-09-30 13:52:24
php-http/client-common 2022-09-29 11:59:43
symfony/stopwatch 2022-09-28 18:00:33
twig/twig 2022-09-28 10:42:51
symfony/filesystem 2022-09-21 22:28:48
friendsofsymfony/rest-bundle 2022-09-18 06:54:54
jms/serializer-bundle 2022-09-13 21:27:18
jms/metadata 2022-09-13 21:18:27
jms/serializer 2022-09-12 10:40:16
dragonmantank/cron-expression 2022-09-10 14:51:20
deployer/deployer 2022-09-10 07:44:30
scheb/2fa-trusted-device 2022-09-04 17:52:28
scheb/2fa-email 2022-09-04 17:52:28
scheb/2fa-bundle 2022-09-04 17:52:28
doctrine/collections 2022-09-01 22:12:10
symfony/asset 2022-08-31 10:17:45
guzzlehttp/guzzle 2022-08-28 16:39:27
guzzlehttp/promises 2022-08-28 15:55:35
lcobucci/jwt 2022-08-20 01:14:07
masterminds/html5 2022-08-18 18:18:26
sulu/article-bundle 2022-08-16 23:21:32
sulu/automation-bundle 2022-08-16 17:16:37
jackalope/jackalope-doctrine-dbal 2022-08-12 16:00:08
brick/math 2022-08-11 00:54:19
symfony/flex 2022-08-07 11:39:47
doctrine/migrations 2022-08-04 15:29:49
symfony/finder 2022-07-29 09:42:06
handcraftedinthealps/elasticsearch-dsl 2022-07-25 14:58:49
php-task/task-bundle 2022-07-25 14:38:27
monolog/monolog 2022-07-24 14:00:55
php-task/php-task 2022-07-22 11:37:53
symfony/config 2022-07-20 17:00:40
symfony/password-hasher 2022-07-20 16:45:06
symfony/security-bundle 2022-07-20 15:46:29
sulu/form-bundle 2022-07-15 12:57:03
sendinblue/api-v3-sdk 2022-07-13 14:44:38
php-http/discovery 2022-07-11 16:04:40
handcraftedinthealps/goodby-csv 2022-07-08 13:57:03
symfony/var-exporter 2022-07-04 17:54:52
doctrine/phpcr-bundle 2022-07-04 10:39:11
symfony-cmf/routing 2022-07-04 09:08:15
friendsofsymfony/jsrouting-bundle 2022-07-01 13:50:22
symfony/templating 2022-06-27 19:24:16
symfony/runtime 2022-06-27 19:24:16
symfony/process 2022-06-27 19:24:16
symfony/css-selector 2022-06-27 19:24:16
nyholm/psr7 2022-06-22 09:13:36
symfony/monolog-bridge 2022-06-21 10:28:57
symfony-cmf/routing-bundle 2022-06-19 16:14:36
egulias/email-validator 2022-06-18 22:57:19
webmozart/assert 2022-06-03 20:03:27
symfony/service-contracts 2022-05-30 21:18:58
symfony/twig-bundle 2022-05-27 18:55:36
doctrine/sql-formatter 2022-05-23 23:33:49
doctrine/cache 2022-05-20 22:06:54
symfony/security-csrf 2022-05-14 14:53:54
symfony/monolog-bundle 2022-05-10 16:24:36
symfony/event-dispatcher 2022-05-05 18:51:07
dantleech/phpcr-migrations-bundle 2022-05-02 18:07:13
doctrine/deprecations 2022-05-02 17:47:09
phpcr/phpcr-shell 2022-05-02 15:55:09
jackalope/jackalope 2022-05-02 14:09:45
phpcr/phpcr-migrations 2022-05-02 13:08:46
doctrine/doctrine-fixtures-bundle 2022-04-28 19:58:29
symfony/http-client-contracts 2022-04-21 12:29:03
massive/build-bundle 2022-04-21 09:12:35
handcraftedinthealps/rest-routing-bundle 2022-04-20 20:11:06
lcobucci/clock 2022-04-19 21:34:17
doctrine/data-fixtures 2022-04-19 12:01:44
symfony/dotenv 2022-03-31 18:23:12
behat/transliterator 2022-03-30 11:27:43
doctrine/instantiator 2022-03-03 09:28:38
symfony/proxy-manager-bridge 2022-03-02 14:21:45
doctrine/lexer 2022-02-28 12:07:21
php-http/httplug 2022-02-21 10:52:22
php-http/message 2022-02-11 14:41:14
react/promise 2022-02-11 11:27:51
symfony/options-resolver 2022-02-09 15:00:38
doctrine/doctrine-migrations-bundle 2022-02-01 19:08:07
willdurand/jsonp-callback-validator 2022-01-30 21:33:09
willdurand/negotiation 2022-01-30 21:08:53
clue/stream-filter 2022-01-21 10:50:44
composer/package-versions-deprecated 2022-01-17 15:14:24
twig/extra-bundle 2022-01-03 16:46:28
twig/string-extra 2022-01-02 11:02:25
symfony/event-dispatcher-contracts 2022-01-02 10:53:40
toflar/psr6-symfony-http-cache-store 2021-12-21 13:52:29
psr/container 2021-11-05 17:47:00
ramsey/collection 2021-10-09 22:00:34
jean85/pretty-package-versions 2021-10-08 23:21:46
contao/imagine-svg 2021-08-10 11:33:50
http-interop/http-factory-guzzle 2021-07-21 08:50:14
psr/log 2021-07-14 11:46:02
psr/cache 2021-02-03 17:26:27
symfony-cmf/slugifier-api 2021-01-22 10:05:45
handcraftedinthealps/zendsearch 2021-01-07 16:15:54
oro/doctrine-extensions 2020-12-25 17:46:26
phpcr/phpcr 2020-10-06 11:05:27
php-http/promise 2020-07-07 11:29:14
psr/http-client 2020-06-29 08:28:15
google/recaptcha 2020-03-31 18:50:54
mustangostang/spyc 2019-09-10 09:16:29
psr/http-factory 2019-04-30 07:38:16
ralouphie/getallheaders 2019-03-08 03:55:37
psr/event-dispatcher 2019-01-08 12:20:26
dantleech/glob-finder 2016-08-23 15:48:07
psr/http-message 2016-08-06 09:39:51
php-http/message-factory 2015-12-19 15:08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment