本文整理汇总了PHP中Composer\Config::merge方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::merge方法的具体用法?PHP Config::merge怎么用?PHP Config::merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Config
的用法示例。
在下文中一共展示了Config::merge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createConfig
/**
* @return Config
*/
public static function createConfig()
{
// load main Composer configuration
if (!($home = getenv('COMPOSER_HOME'))) {
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
$home = getenv('APPDATA') . '/Composer';
} else {
$home = getenv('HOME') . '/.composer';
}
}
// Protect directory against web access
if (!file_exists($home . '/.htaccess')) {
if (!is_dir($home)) {
@mkdir($home, 0777, true);
}
@file_put_contents($home . '/.htaccess', 'Deny from all');
}
$config = new Config();
$file = new JsonFile($home . '/config.json');
if ($file->exists()) {
$config->merge($file->read());
}
// add home dir to the config
$config->merge(array('config' => array('home' => $home)));
return $config;
}
示例2: testOverrideGithubProtocols
public function testOverrideGithubProtocols()
{
$config = new Config(false);
$config->merge(array('config' => array('github-protocols' => array('https', 'git'))));
$config->merge(array('config' => array('github-protocols' => array('https'))));
$this->assertEquals(array('https'), $config->get('github-protocols'));
}
示例3: createConfig
public static function createConfig(IOInterface $io = null, $cwd = null)
{
$cwd = $cwd ?: getcwd();
$home = self::getHomeDir();
$cacheDir = self::getCacheDir($home);
foreach (array($home, $cacheDir) as $dir) {
if (!file_exists($dir . '/.htaccess')) {
if (!is_dir($dir)) {
@mkdir($dir, 0777, true);
}
@file_put_contents($dir . '/.htaccess', 'Deny from all');
}
}
$config = new Config(true, $cwd);
$config->merge(array('config' => array('home' => $home, 'cache-dir' => $cacheDir)));
$file = new JsonFile($config->get('home') . '/config.json');
if ($file->exists()) {
if ($io && $io->isDebug()) {
$io->writeError('Loading config file ' . $file->getPath());
}
$config->merge($file->read());
}
$config->setConfigSource(new JsonConfigSource($file));
$file = new JsonFile($config->get('home') . '/auth.json');
if ($file->exists()) {
if ($io && $io->isDebug()) {
$io->writeError('Loading config file ' . $file->getPath());
}
$config->merge(array('config' => $file->read()));
}
$config->setAuthConfigSource(new JsonConfigSource($file, true));
return $config;
}
示例4: setUp
protected function setUp()
{
$this->fs = new Filesystem();
$this->composer = new Composer();
$this->config = new Config();
$this->composer->setConfig($this->config);
$this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-vendor';
$this->ensureDirectoryExistsAndClear($this->vendorDir);
$this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-bin';
$this->ensureDirectoryExistsAndClear($this->binDir);
$this->config->merge(array('config' => array('vendor-dir' => $this->vendorDir, 'bin-dir' => $this->binDir)));
$this->dm = $this->getMockBuilder('Composer\\Downloader\\DownloadManager')->disableOriginalConstructor()->getMock();
/* @var DownloadManager $dm */
$dm = $this->dm;
$this->composer->setDownloadManager($dm);
$this->repository = $this->getMock('Composer\\Repository\\InstalledRepositoryInterface');
$this->io = $this->getMock('Composer\\IO\\IOInterface');
$this->type = $this->getMock('Fxp\\Composer\\AssetPlugin\\Type\\AssetTypeInterface');
$this->type->expects($this->any())->method('getName')->will($this->returnValue('foo'));
$this->type->expects($this->any())->method('getComposerVendorName')->will($this->returnValue('foo-asset'));
$this->type->expects($this->any())->method('getComposerType')->will($this->returnValue('foo-asset-library'));
$this->type->expects($this->any())->method('getFilename')->will($this->returnValue('foo.json'));
$this->type->expects($this->any())->method('getVersionConverter')->will($this->returnValue($this->getMock('Fxp\\Composer\\AssetPlugin\\Converter\\VersionConverterInterface')));
$this->type->expects($this->any())->method('getPackageConverter')->will($this->returnValue($this->getMock('Fxp\\Composer\\AssetPlugin\\Converter\\PackageConverterInterface')));
}
示例5: testAddPackagistRepository
/**
* @dataProvider dataAddPackagistRepository
*/
public function testAddPackagistRepository($expected, $localConfig, $systemConfig = null)
{
$config = new Config();
if ($systemConfig) {
$config->merge(array('repositories' => $systemConfig));
}
$config->merge(array('repositories' => $localConfig));
$this->assertEquals($expected, $config->getRepositories());
}
示例6: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
// Run through the Library Installer Test set up.
parent::setUp();
// Also be sure to set up the Component directory.
$this->componentDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-component';
$this->ensureDirectoryExistsAndClear($this->componentDir);
// Merge the component-dir setting in so that it applies correctly.
$this->config->merge(array('config' => array('component-dir' => $this->componentDir)));
}
示例7: setUp
public function setUp()
{
$this->config = new Config();
$this->config->merge(array(
'config' => array(
'home' => sys_get_temp_dir() . '/composer-test',
'cache-repo-dir' => sys_get_temp_dir() . '/composer-test-cache',
),
));
}
示例8: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->localConfigPath = realpath(__DIR__ . '/../fixtures/local');
$this->globalConfigPath = realpath(__DIR__ . '/../fixtures/home');
$this->config = new Config(false, $this->localConfigPath);
$this->config->merge(['config' => ['home' => $this->globalConfigPath]]);
$package = new RootPackage('my/project', '1.0.0', '1.0.0');
$package->setExtra(['my-local-config' => ['foo' => 'bar']]);
$this->composer = new Composer();
$this->composer->setConfig($this->config);
$this->composer->setPackage($package);
$this->SUT = new ConfigLocator($this->composer);
}
示例9: setUp
protected function setUp()
{
$this->tempDir = TestUtil::makeTempDir('puli-composer-plugin', __CLASS__);
$filesystem = new Filesystem();
$filesystem->mirror(__DIR__ . '/Fixtures/root', $this->tempDir);
$this->io = $this->getMock('Composer\\IO\\IOInterface');
$this->config = new Config(false, $this->tempDir);
$this->config->merge(array('config' => array('vendor-dir' => 'the-vendor')));
$this->installationManager = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock();
$this->installationManager->expects($this->any())->method('getInstallPath')->will($this->returnCallback(array($this, 'getInstallPath')));
$this->rootPackage = new RootPackage('vendor/root', '1.0', '1.0');
$this->rootPackage->setRequires(array('vendor/package1' => new Link('vendor/root', 'vendor/package1'), 'vendor/package2' => new Link('vendor/root', 'vendor/package2')));
$this->localRepository = new TestLocalRepository(array(new Package('vendor/package1', '1.0', '1.0'), new Package('vendor/package2', '1.0', '1.0')));
$this->repositoryManager = new RepositoryManager($this->io, $this->config);
$this->repositoryManager->setLocalRepository($this->localRepository);
$this->installPaths = array();
$this->composer = new Composer();
$this->composer->setRepositoryManager($this->repositoryManager);
$this->composer->setInstallationManager($this->installationManager);
$this->composer->setConfig($this->config);
$this->composer->setPackage($this->rootPackage);
$this->puliRunner = $this->getMockBuilder('Puli\\ComposerPlugin\\PuliRunner')->disableOriginalConstructor()->getMock();
$this->previousWd = getcwd();
chdir($this->tempDir);
$this->plugin = new PuliPlugin($this->puliRunner);
}
示例10: setUp
protected function setUp()
{
while (false === mkdir($this->tempDir = sys_get_temp_dir() . '/puli-plugin/PuliPluginTest_root' . rand(10000, 99999), 0777, true)) {
}
$filesystem = new Filesystem();
$filesystem->mirror(__DIR__ . '/Fixtures/root', $this->tempDir);
$this->io = $this->getMock('Composer\\IO\\IOInterface');
$this->config = new Config(false, $this->tempDir);
$this->config->merge(array('config' => array('vendor-dir' => 'the-vendor')));
$this->installationManager = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock();
$this->installationManager->expects($this->any())->method('getInstallPath')->will($this->returnCallback(array($this, 'getInstallPath')));
$this->rootPackage = new RootPackage('vendor/root', '1.0', '1.0');
$this->localRepository = new TestLocalRepository(array(new Package('vendor/package1', '1.0', '1.0'), new Package('vendor/package2', '1.0', '1.0')));
$this->repositoryManager = new RepositoryManager($this->io, $this->config);
$this->repositoryManager->setLocalRepository($this->localRepository);
$this->installPaths = array();
$this->composer = new Composer();
$this->composer->setRepositoryManager($this->repositoryManager);
$this->composer->setInstallationManager($this->installationManager);
$this->composer->setConfig($this->config);
$this->composer->setPackage($this->rootPackage);
$this->puliRunner = $this->getMockBuilder('Puli\\ComposerPlugin\\PuliRunner')->disableOriginalConstructor()->getMock();
$this->previousWd = getcwd();
chdir($this->tempDir);
$this->plugin = new PuliPlugin($this->puliRunner);
}
示例11: setUp
protected function setUp()
{
/* @var IOInterface $io */
$io = $this->getMock('Composer\IO\IOInterface');
$config = new Config();
$config->merge(array(
'config' => array(
'home' => sys_get_temp_dir() . '/composer-test',
'cache-repo-dir' => sys_get_temp_dir() . '/composer-test-cache-repo',
),
));
$rm = new RepositoryManager($io, $config);
$rm->setRepositoryClass($this->getType() . '-vcs', 'Fxp\Composer\AssetPlugin\Tests\Fixtures\Repository\MockAssetRepository');
$repoConfig = array(
'repository-manager' => $rm,
'asset-options' => array(
'searchable' => true,
),
);
$this->io = $io;
$this->config = $config;
$this->rm = $rm;
$this->registry = $this->getRegistry($repoConfig, $io, $config);
$this->pool = $this->getMock('Composer\DependencyResolver\Pool');
}
示例12: getConfig
protected function getConfig()
{
$config = new Config();
$settings = array('config' => array('home' => $this->testPath));
$config->merge($settings);
return $config;
}
示例13: prepareController
/**
* Mock the controller.
*
* @return \PHPUnit_Framework_MockObject_MockObject|PackageController
*/
private function prepareController()
{
$manager = $this->getMockBuilder(RepositoryManager::class)->disableOriginalConstructor()->setMethods(null)->getMock();
$config = new Config();
$config->merge(array('repositories' => array('packagist' => false)));
$loader = new RootPackageLoader($manager, $config);
$rootPackage = $loader->load(json_decode($this->readFixture('composer.json'), true));
$loader = new ArrayLoader();
$json = json_decode($this->readFixture('installed.json'), true);
$packages = [];
foreach ($json as $package) {
$packages[] = $loader->load($package);
}
$manager->setLocalRepository(new WritableArrayRepository($packages));
$composer = $this->getMockBuilder(Composer::class)->setMethods(['getPackage', 'getRepositoryManager'])->getMock();
$composer->method('getPackage')->willReturn($rootPackage);
$composer->method('getRepositoryManager')->willReturn($manager);
$controller = $this->getMockBuilder(PackageController::class)->setMethods(['getComposer', 'forward'])->getMock();
$controller->method('getComposer')->willReturn($composer);
$home = $this->getMock(HomePathDeterminator::class, ['homeDir']);
$home->method('homeDir')->willReturn($this->getTempDir());
$composerJson = $this->provideFixture('composer.json');
$this->provideFixture('composer.lock');
$this->provideFixture('installed.json', 'vendor/composer/installed.json');
$container = new Container();
$container->set('tenside.home', $home);
$container->set('tenside.composer_json', new ComposerJson($composerJson));
/** @var PackageController $controller */
$controller->setContainer($container);
return $controller;
}
示例14: has
/**
* Search for a given package version.
*
* Usage examples : Composition::has('php', '5.3.*') // PHP version
* Composition::has('ext-memcache') // PHP extension
* Composition::has('vendor/package', '>2.1') // Package version
*
* @param type $packageName The package name
* @param type $prettyString An optional version constraint
*
* @return boolean Wether or not the package has been found.
*/
public static function has($packageName, $prettyString = '*')
{
if (null === self::$pool) {
if (null === self::$rootDir) {
self::$rootDir = getcwd();
if (!file_exists(self::$rootDir . '/composer.json')) {
throw new \RuntimeException('Unable to guess the project root dir, please specify it manually using the Composition::setRootDir method.');
}
}
$minimumStability = 'dev';
$config = new Config();
$file = new JsonFile(self::$rootDir . '/composer.json');
if ($file->exists()) {
$projectConfig = $file->read();
$config->merge($projectConfig);
if (isset($projectConfig['minimum-stability'])) {
$minimumStability = $projectConfig['minimum-stability'];
}
}
$vendorDir = self::$rootDir . '/' . $config->get('vendor-dir');
$pool = new Pool($minimumStability);
$pool->addRepository(new PlatformRepository());
$pool->addRepository(new InstalledFilesystemRepository(new JsonFile($vendorDir . '/composer/installed.json')));
$pool->addRepository(new InstalledFilesystemRepository(new JsonFile($vendorDir . '/composer/installed_dev.json')));
self::$pool = $pool;
}
$parser = new VersionParser();
$constraint = $parser->parseConstraints($prettyString);
$packages = self::$pool->whatProvides($packageName, $constraint);
return empty($packages) ? false : true;
}
示例15: setUp
/**
* @inheritdoc
*/
protected function setUp()
{
parent::setUp();
$this->fs = new SymlinkFilesystem();
$this->composer = new Composer();
$this->config = new Config();
$this->composer->setConfig($this->config);
$this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-vendor';
$this->ensureDirectoryExistsAndClear($this->vendorDir);
$this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-bin';
$this->ensureDirectoryExistsAndClear($this->binDir);
$this->dependenciesDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-dependencies';
$this->ensureDirectoryExistsAndClear($this->dependenciesDir);
$this->symlinkDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-vendor-shared';
$this->config->merge(array('config' => array('vendor-dir' => $this->vendorDir, 'bin-dir' => $this->binDir)));
$this->dm = $this->getMockBuilder('Composer\\Downloader\\DownloadManager')->disableOriginalConstructor()->getMock();
$this->composer->setDownloadManager($this->dm);
/** @var RootPackage|\PHPUnit_Framework_MockObject_MockObject $package */
$package = $this->getMock('Composer\\Package\\RootPackageInterface');
$package->expects($this->any())->method('getExtra')->willReturn(array(SharedPackageInstaller::PACKAGE_TYPE => array('vendor-dir' => $this->dependenciesDir, 'symlink-dir' => $this->symlinkDir)));
$this->composer->setPackage($package);
$this->repository = $this->getMock('Composer\\Repository\\InstalledRepositoryInterface');
$this->io = $this->getMock('Composer\\IO\\IOInterface');
$this->dataManager = $this->getMockBuilder('LEtudiant\\Composer\\Data\\Package\\SharedPackageDataManager')->disableOriginalConstructor()->getMock();
}