1
0
Fork 0
composer/bin/composer

62 lines
2.2 KiB
Plaintext
Raw Normal View History

2011-04-17 22:39:28 +00:00
#!/usr/bin/env php
<?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;
use Composer\Json\JsonFile;
2011-09-17 11:39:37 +00:00
use Composer\Console\Application as ComposerApplication;
$vendorPath = 'vendor';
// initialize repository manager
$rm = new Repository\RepositoryManager();
$rm->setLocalRepository(new Repository\FilesystemRepository(new JsonFile($vendorPath.'/.composer/installed.json')));
$rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
$rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
$rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
2011-09-15 09:50:50 +00:00
// initialize download manager
$dm = new Downloader\DownloadManager();
$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());
// initialize installation manager
$im = new Installer\InstallationManager();
$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
// load package
$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');
}
$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
// init locker
$locker = new Package\Locker(new JsonFile('composer.lock'), $rm);
// initialize composer
$composer = new Composer();
$composer->setPackage($package);
$composer->setLocker($locker);
$composer->setRepositoryManager($rm);
$composer->setDownloadManager($dm);
$composer->setInstallationManager($im);
// run the command application
$application = new ComposerApplication($composer);
$application->run();