本文整理汇总了PHP中Composer\Composer类的典型用法代码示例。如果您正苦于以下问题:PHP Composer类的具体用法?PHP Composer怎么用?PHP Composer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Composer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: activate
/**
* {@inheritdoc}
*/
public function activate(Composer $composer, IOInterface $io)
{
foreach (static::$types as $type) {
$installer = new WordpressInstaller($io, $composer, $type);
$composer->getInstallationManager()->addInstaller($installer);
}
}
示例2: activate
public function activate(Composer $composer, IOInterface $io)
{
$this->io = $io;
$vendor = $composer->getConfig()->get('vendor-dir', '/');
$this->vendor = $vendor;
$this->root = dirname($vendor);
}
示例3: setUp
public function setUp()
{
$this->config = $this->getMock('Composer\Config');
$this->config->expects($this->any())
->method('get')
->will($this->returnCallback(function ($key) {
switch ($key) {
case 'cache-repo-dir':
return sys_get_temp_dir() . '/composer-test-repo-cache';
case 'vendor-dir':
return sys_get_temp_dir() . '/composer-test/vendor';
}
return null;
}));
$this->rootPackage = $this->getMock('Composer\Package\RootPackageInterface');
$this->package = $this->getMock('Composer\Package\PackageInterface');
$this->package->expects($this->any())
->method('getName')
->will($this->returnValue('foo-asset/foo'));
$this->composer = $this->getMock('Composer\Composer');
$this->composer->expects($this->any())
->method('getPackage')
->will($this->returnValue($this->rootPackage));
$this->composer->expects($this->any())
->method('getConfig')
->will($this->returnValue($this->config));
}
示例4: testSetGetInstallationManager
public function testSetGetInstallationManager()
{
$composer = new Composer();
$manager = $this->getMock('Composer\\Installer\\InstallationManager');
$composer->setInstallationManager($manager);
$this->assertSame($manager, $composer->getInstallationManager());
}
示例5: activate
/**
* @param Composer $composer
* @param IOInterface $io
*/
public function activate(Composer $composer, IOInterface $io)
{
$repositoryManager = $composer->getRepositoryManager();
$extra = $composer->getPackage()->getExtra();
if (!isset($extra['connect-packages'])) {
return;
}
$versionParser = new VersionParser();
$links = [];
foreach ($extra['connect-packages'] as $connectPackage => $version) {
try {
$releases = $this->getVersionsForPackage($connectPackage);
} catch (InvalidArgumentException $e) {
$message = '<error>Could not find release manifest for module with extension key: "%s". ';
$message .= 'Did you get the casing right? Error: "%s"</error>';
$io->writeError(sprintf($message, $connectPackage, $e->getMessage()), true);
continue;
} catch (UnexpectedValueException $e) {
$message = '<error>Non valid XML return from connect for module with extension key: "%s".</error>';
$message .= $e->getMessage();
$io->writeError(sprintf($message, $connectPackage), true);
continue;
}
$repository = $this->addPackages($releases, $connectPackage);
$repositoryManager->addRepository($repository);
$constraint = $versionParser->parseConstraints($version);
$links[] = new Link($composer->getPackage()->getName(), $connectPackage, $constraint);
}
if (!empty($links)) {
$requires = $composer->getPackage()->getRequires();
$requires = array_merge($requires, $links);
$composer->getPackage()->setRequires($requires);
}
}
示例6: activate
/**
* {@inheritDoc}
*/
public function activate(Composer $composer, IOInterface $io)
{
$pluginInstaller = new PluginInstaller($io, $composer);
$composer->getInstallationManager()->addInstaller($pluginInstaller);
//$themeInstaller = new ThemeInstaller($io, $composer);
//$composer->getInstallationManager()->addInstaller($themeInstaller);
}
示例7: testGetLocations
/**
* Test getLocations returning appropriate values based on CakePHP version
*
*/
public function testGetLocations()
{
$package = new RootPackage('CamelCased', '1.0', '1.0');
$composer = new Composer();
$rm = new RepositoryManager($this->getMock('Composer\\IO\\IOInterface'), $this->getMock('Composer\\Config'));
$composer->setRepositoryManager($rm);
$installer = new CakePHPInstaller($package, $composer);
// 2.0 < cakephp < 3.0
$this->setCakephpVersion($rm, '2.0.0');
$result = $installer->getLocations();
$this->assertContains('Plugin/', $result['plugin']);
$this->setCakephpVersion($rm, '2.5.9');
$result = $installer->getLocations();
$this->assertContains('Plugin/', $result['plugin']);
$this->setCakephpVersion($rm, '~2.5');
$result = $installer->getLocations();
$this->assertContains('Plugin/', $result['plugin']);
// special handling for 2.x versions when 3.x is still in development
$this->setCakephpVersion($rm, 'dev-master');
$result = $installer->getLocations();
$this->assertContains('Plugin/', $result['plugin']);
$this->setCakephpVersion($rm, '>=2.5');
$result = $installer->getLocations();
$this->assertContains('Plugin/', $result['plugin']);
// cakephp >= 3.0
$this->setCakephpVersion($rm, '3.0.*-dev');
$result = $installer->getLocations();
$this->assertContains('plugins/', $result['plugin']);
$this->setCakephpVersion($rm, '~8.8');
$result = $installer->getLocations();
$this->assertContains('plugins/', $result['plugin']);
}
示例8: activate
public function activate(Composer $composer, IOInterface $io)
{
// Add the Innomatic legacy platform installer
$composer->getInstallationManager()->addInstaller(new LegacyPlatformInstaller($io, $composer));
// Add the Innomatic legacy application installer
$composer->getInstallationManager()->addInstaller(new LegacyApplicationInstaller($io, $composer));
}
示例9: __construct
/**
* @param \Composer\Composer $composer
* @param \Composer\Util\Filesystem $filesystem
*/
public function __construct(\Composer\Composer $composer, \Composer\Util\Filesystem $filesystem = NULL)
{
$this->composer = $composer;
$this->downloadManager = $composer->getDownloadManager();
$this->filesystem = $filesystem ?: new \Composer\Util\Filesystem();
$this->extensionDir = self::TYPO3_CONF_DIR . DIRECTORY_SEPARATOR . self::TYPO3_EXT_DIR;
}
示例10: createComposerInstance
private function createComposerInstance()
{
$composer = new Composer();
$config = new Config();
$composer->setConfig($config);
return $composer;
}
示例11: getPackageInstallPath
public static function getPackageInstallPath(PackageInterface $package, Composer $composer)
{
$prettyName = $package->getPrettyName();
if (strpos($prettyName, '/') !== false) {
list($vendor, $name) = explode('/', $prettyName);
} else {
$vendor = '';
$name = $prettyName;
}
$availableVars = compact('name', 'vendor');
$extra = $package->getExtra();
if (!empty($extra['installer-name'])) {
$availableVars['name'] = $extra['installer-name'];
}
if ($composer->getPackage()) {
$extra = $composer->getPackage()->getExtra();
if (!empty($extra['installer-paths'])) {
$customPath = self::mapCustomInstallPaths($extra['installer-paths'], $prettyName);
if (false !== $customPath) {
return self::templatePath($customPath, $availableVars);
}
}
}
return NULL;
}
示例12: callRecursive
/**
* Call extra recursive
* @param Composer $composer
* @param IExtra $extra
*/
private function callRecursive(Composer $composer, IExtra $extra)
{
$extra->run($composer->getPackage(), true);
foreach ($composer->getRepositoryManager()->getLocalRepository()->getPackages() as $package) {
$extra->run($package, false);
}
}
示例13: activate
public function activate(Composer $composer, IO\IOInterface $io)
{
$this->composer = $composer;
$this->config = $composer->getConfig();
$this->io = $io;
$this->pluginConfig = $this->setPluginConfig();
}
示例14: getConsoleCommands
public static function getConsoleCommands(Composer $composer)
{
$commands = array(array('yiic', 'migrate'));
if ($composer->getPackage()) {
$extra = $composer->getPackage()->getExtra();
if (!empty($extra['yiicomposer-console-commands'])) {
$tmp = $extra['yiicomposer-console-commands'];
}
if (!empty($tmp)) {
$commands = array();
foreach ($tmp as $c) {
$command = array();
$command[] = 'yiic';
$command[] = $c['controller'];
if (!empty($c['action'])) {
$command[] = $c['action'];
}
if (!empty($c['params'])) {
$command = array_merge($command, $c['params']);
}
if (!empty($c['params'])) {
foreach ($c['params'] as $k => $v) {
$command[] = '--' . $k . '=' . $v;
}
}
$commands[] = $command;
}
}
}
return $commands;
}
示例15: __construct
public function __construct(PackageInterface $package = null, Composer $composer = null, IOInterface $io = null)
{
if (null === $package) {
$package = $composer->getPackage();
}
$extraOxidRoot = $extraModuleVendor = false;
if (null !== $package) {
$extra = $package->getExtra();
if (isset($extra['oxid-root'])) {
foreach ($this->locations as $name => $location) {
$this->locations[$name] = "{$extra['oxid-root']}/{$location}";
}
$extraOxidRoot = true;
}
if (isset($extra['module-vendor'])) {
$this->locations['module'] = str_replace('modules/', "modules/{$extra['module-vendor']}/", $this->locations['module']);
$extraModuleVendor = true;
}
}
$composerPackage = $composer->getPackage();
if (null !== $composerPackage) {
$extra = $composerPackage->getExtra();
if (isset($extra['oxid-root']) && !$extraOxidRoot) {
foreach ($this->locations as $name => $location) {
$this->locations[$name] = "{$extra['oxid-root']}/{$location}";
}
}
if (isset($extra['module-vendor']) && !$extraModuleVendor) {
$this->locations['module'] = str_replace('modules/', "modules/{$extra['module-vendor']}/", $this->locations['module']);
}
}
parent::__construct($package, $composer, $io);
}