<?php require "include/main.php"; date_default_timezone_set('Europe/Paris'); $db = new PDO("mysql:dbname=" . MYBASE . ";host=" . MYHOST, MYUSER, MYPASS); $pk = new PackagistClient(); $pkg = new TablePackagist($db); foreach ($pkg->request(array('ORDER' => 'rpmname')) as $rec) { if ($rep = $pk->getPackage($rec['pkgname'])) { printf("%-40s %-12s %-12s %s\n", $rep['name'], $rep['stable'], $rep['unstable'], $rep['state']); } } var_dump($pk->getPackage('unkwnown/dontexists'));
/** * Parse the content of all Packagist repository * * @param TableUpstream $uptable the table to write to * @param TablePackagist $pktable the table to read from * * @return integer number of parsed line */ public static function readPackagist(TableUpstream $uptable, TablePackagist $pktable) { self::log("Packagist search releases"); $pk = new PackagistClient(); $nb = $uptable->delete(array('type' => 'composer')); self::log("Delete {$nb} packages"); $tot = 0; foreach ($pktable->request(array('ORDER' => 'rpmname')) as $rec) { if ($rep = $pk->getPackage($rec['pkgname'])) { $v = explode('/', $rec['pkgname']); switch (count($v)) { case 3: $vendor = $v[0] . '/' . $v[1]; break; case 2: $vendor = "packagist/" . $v[0]; break; default: $vendor = "packagist"; } $id = false; if ($rep['stable']) { $id = $uptable->record('composer', $vendor, $rec['rpmname'], $rep['stable'], true); } if ($rep['unstable']) { $id = $uptable->record('composer', $vendor, $rec['rpmname'], $rep['unstable'], false, $rep['state']); } if ($id) { $tot++; } } } self::log("Write {$tot} packages"); return $tot; }