2011-04-17 22:39:28 +00:00
|
|
|
#!/usr/bin/env php
|
2011-04-17 22:14:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require __DIR__.'/../tests/bootstrap.php';
|
|
|
|
|
|
|
|
use Composer\Composer;
|
2011-09-17 11:39:37 +00:00
|
|
|
use Composer\Installer;
|
|
|
|
use Composer\Downloader;
|
|
|
|
use Composer\Repository;
|
|
|
|
use Composer\Package;
|
2011-10-01 12:33:43 +00:00
|
|
|
use Composer\Json\JsonFile;
|
2011-09-17 11:39:37 +00:00
|
|
|
use Composer\Console\Application as ComposerApplication;
|
2011-04-17 22:14:44 +00:00
|
|
|
|
2011-10-29 16:13:11 +00:00
|
|
|
$vendorPath = 'vendor';
|
|
|
|
|
2011-09-25 18:00:44 +00:00
|
|
|
// initialize repository manager
|
|
|
|
$rm = new Repository\RepositoryManager();
|
2011-10-29 16:13:11 +00:00
|
|
|
$rm->setLocalRepository(new Repository\FilesystemRepository(new JsonFile($vendorPath.'/.composer/installed.json')));
|
2011-10-22 18:49:19 +00:00
|
|
|
$rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
|
|
|
|
$rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
|
2011-10-22 20:22:11 +00:00
|
|
|
$rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
|
2011-09-15 09:50:50 +00:00
|
|
|
|
2011-09-25 18:00:44 +00:00
|
|
|
// initialize download manager
|
2011-10-30 19:59:41 +00:00
|
|
|
$dm = new Downloader\DownloadManager();
|
2011-09-25 18:00:44 +00:00
|
|
|
$dm->setDownloader('git', new Downloader\GitDownloader());
|
2011-09-25 21:43:49 +00:00
|
|
|
$dm->setDownloader('pear', new Downloader\PearDownloader());
|
|
|
|
$dm->setDownloader('zip', new Downloader\ZipDownloader());
|
2011-09-25 18:00:44 +00:00
|
|
|
|
|
|
|
// initialize installation manager
|
|
|
|
$im = new Installer\InstallationManager();
|
2011-10-29 16:13:11 +00:00
|
|
|
$im->addInstaller(new Installer\LibraryInstaller($vendorPath, $dm, $rm->getLocalRepository()));
|
|
|
|
$im->addInstaller(new Installer\LibraryInstaller($vendorPath.'/bundles', $dm, $rm->getLocalRepository(), 'symfony-bundle'));
|
2011-09-17 11:39:37 +00:00
|
|
|
|
2011-09-25 18:00:44 +00:00
|
|
|
// load package
|
2011-10-22 20:23:45 +00:00
|
|
|
$loader = new Package\Loader\ArrayLoader($rm);
|
|
|
|
$file = new JsonFile('composer.json');
|
2011-10-30 20:13:49 +00:00
|
|
|
if (!$file->exists()) {
|
|
|
|
throw new \RuntimeException('The composer.json file could not be found in the current directory');
|
|
|
|
}
|
2011-10-22 20:23:45 +00:00
|
|
|
$packageConfig = $file->read();
|
|
|
|
$package = $loader->load($packageConfig);
|
|
|
|
|
|
|
|
// load default repository unless it's explicitly disabled
|
|
|
|
if (!isset($packageConfig['repositories']['packagist']) || $packageConfig['repositories']['packagist'] !== false) {
|
|
|
|
$rm->addRepository(new Repository\ComposerRepository('http://packagist.org'));
|
|
|
|
}
|
2011-09-17 11:39:37 +00:00
|
|
|
|
2011-10-01 12:33:43 +00:00
|
|
|
// init locker
|
|
|
|
$locker = new Package\Locker(new JsonFile('composer.lock'), $rm);
|
|
|
|
|
2011-09-25 18:00:44 +00:00
|
|
|
// initialize composer
|
|
|
|
$composer = new Composer();
|
|
|
|
$composer->setPackage($package);
|
2011-10-01 12:33:43 +00:00
|
|
|
$composer->setLocker($locker);
|
2011-09-25 18:00:44 +00:00
|
|
|
$composer->setRepositoryManager($rm);
|
|
|
|
$composer->setDownloadManager($dm);
|
|
|
|
$composer->setInstallationManager($im);
|
2011-04-17 22:14:44 +00:00
|
|
|
|
2011-09-14 12:57:40 +00:00
|
|
|
// run the command application
|
2011-09-25 18:00:44 +00:00
|
|
|
$application = new ComposerApplication($composer);
|
2011-09-14 12:57:40 +00:00
|
|
|
$application->run();
|