Is it possible to call composer update from application code with dry-run thru \Composer\ namespace to get information about udpates ?
I have searched in google and found only info about Composer plugins or writing (post|pre)-(install|update) hook scripts, but haven't found any info about getting such information.
SOLVED:
Worked putting custom composer script in pre-update-cmd:
<?php
namespace MyNamespace;
use Composer\Script\Event;
use Composer\Plugin\CommandEvent;
use Composer\Plugin\PluginEvents;
class CheckStatus
{
public static function preUpdate(Event $event)
{
/* get composer */
$composer = $event->getComposer();
$installedRepo = $composer->getRepositoryManager()->getLocalRepository();
$dm = $composer->getDownloadManager();
$im = $composer->getInstallationManager();
$errors = array();
/* list packages */
foreach ($installedRepo->getPackages() as $package) {
$downloader = $dm->getDownloaderForInstalledPackage($package);
if ($downloader instanceof ChangeReportInterface) {
$targetDir = $im->getInstallPath($package);
if ($changes = $downloader->getLocalChanges($package, $targetDir)) {
$errors[$targetDir] = $changes;
}
}
}
if (!$errors) {
$status['changes'] = null;
} else {
$status['changes'] = $errors;
}
// in $status['changes'] we have all pending updates
}
}
</code>