1
0
Fork 0
composer/bin/composer

51 lines
1.7 KiB
PHP
Executable File

#!/usr/bin/env php
<?php
require __DIR__.'/../tests/bootstrap.php';
use Composer\Composer;
use Composer\Installer;
use Composer\Downloader;
use Composer\Repository;
use Composer\Package;
use Composer\Json\JsonFile;
use Composer\Console\Application as ComposerApplication;
// initialize repository manager
$rm = new Repository\RepositoryManager();
$rm->setLocalRepository(new Repository\PlatformRepository(
new Repository\FilesystemRepository(new JsonFile('.composer/installed.json'))
));
$rm->setRepository('Packagist', new Repository\ComposerRepository('http://packagist.org'));
// initialize download manager
$dm = new Downloader\DownloadManager($preferSource = false);
$dm->setDownloader('git', new Downloader\GitDownloader());
$dm->setDownloader('pear', new Downloader\PearDownloader());
$dm->setDownloader('zip', new Downloader\ZipDownloader());
// initialize installation manager
$im = new Installer\InstallationManager();
$im->setInstaller('library', new Installer\LibraryInstaller('vendor', $dm, $rm->getLocalRepository()));
$im->setInstaller('symfony-bundle', new Installer\LibraryInstaller('vendor/bundles', $dm, $rm->getLocalRepository()));
// load package
$loader = new Package\Loader\JsonLoader();
$package = $loader->load(new JsonFile('composer.json'));
// 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();