当前位置: 首页>>代码示例>>PHP>>正文


PHP Config::setConfigSource方法代码示例

本文整理汇总了PHP中Composer\Config::setConfigSource方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::setConfigSource方法的具体用法?PHP Config::setConfigSource怎么用?PHP Config::setConfigSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Composer\Config的用法示例。


在下文中一共展示了Config::setConfigSource方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:VicDeo,项目名称:poc,代码行数:33,代码来源:Factory.php

示例2: testRedirectUrlWithNonexistentRepository

 /**
  * @dataProvider getAssetTypes
  */
 public function testRedirectUrlWithNonexistentRepository($type, $filename)
 {
     $this->setExpectedException('RuntimeException');
     $repoUrl = 'http://github.com/composer-test/repo-name';
     $repoApiUrl = 'https://api.github.com/repos/composer-test/repo-name';
     $identifier = 'v0.0.0';
     $io = $this->getMock('Composer\\IO\\IOInterface');
     $io->expects($this->any())->method('isInteractive')->will($this->returnValue(true));
     $remoteFilesystem = $this->getMockBuilder('Composer\\Util\\RemoteFilesystem')->setConstructorArgs(array($io))->getMock();
     $remoteFilesystem->expects($this->at(0))->method('getContents')->with($this->equalTo('github.com'), $this->equalTo($repoApiUrl), $this->equalTo(false))->will($this->throwException(new TransportException('HTTP/1.1 404 Not Found', 404)));
     $io->expects($this->once())->method('ask')->with($this->equalTo('Username: '))->will($this->returnValue('someuser'));
     $io->expects($this->once())->method('askAndHideAnswer')->with($this->equalTo('Password: '))->will($this->returnValue('somepassword'));
     $io->expects($this->any())->method('setAuthentication')->with($this->equalTo('github.com'), $this->matchesRegularExpression('{someuser|abcdef}'), $this->matchesRegularExpression('{somepassword|x-oauth-basic}'));
     $remoteFilesystem->expects($this->at(1))->method('getContents')->with($this->equalTo('github.com'), $this->equalTo('https://github.com/composer-test/repo-name'), $this->equalTo(false))->will($this->throwException(new TransportException('HTTP/1.1 404 Not Found', 404)));
     $remoteFilesystem->expects($this->at(2))->method('getContents')->with($this->equalTo('github.com'), $this->equalTo($repoApiUrl), $this->equalTo(false))->will($this->throwException(new TransportException('HTTP/1.1 404 Not Found', 404)));
     $remoteFilesystem->expects($this->at(3))->method('getContents')->with($this->equalTo('github.com'), $this->equalTo('https://api.github.com/authorizations'), $this->equalTo(false))->will($this->returnValue('[]'));
     $remoteFilesystem->expects($this->at(4))->method('getContents')->with($this->equalTo('github.com'), $this->equalTo('https://api.github.com/authorizations'), $this->equalTo(false))->will($this->returnValue('{"token": "abcdef"}'));
     $remoteFilesystem->expects($this->at(5))->method('getContents')->with($this->equalTo('github.com'), $this->equalTo($repoApiUrl), $this->equalTo(false))->will($this->throwException(new TransportException('HTTP/1.1 404 Not Found', 404)));
     $remoteFilesystem->expects($this->at(6))->method('getContents')->with($this->equalTo('github.com'), $this->equalTo($repoApiUrl . '/contents/' . $filename . '?ref=' . $identifier), $this->equalTo(false))->will($this->throwException(new TransportException('HTTP/1.1 404 Not Found', 404)));
     $configSource = $this->getMock('Composer\\Config\\ConfigSourceInterface');
     $authConfigSource = $this->getMock('Composer\\Config\\ConfigSourceInterface');
     /* @var ConfigSourceInterface $configSource */
     /* @var ConfigSourceInterface $authConfigSource */
     $this->config->setConfigSource($configSource);
     $this->config->setAuthConfigSource($authConfigSource);
     $repoConfig = array('url' => $repoUrl, 'asset-type' => $type, 'filename' => $filename);
     /* @var IOInterface $io */
     /* @var RemoteFilesystem $remoteFilesystem */
     $gitHubDriver = new GitHubDriver($repoConfig, $io, $this->config, null, $remoteFilesystem);
     $firstNonexistent = false;
     try {
         $gitHubDriver->initialize();
     } catch (TransportException $e) {
         $firstNonexistent = true;
     }
     $this->assertTrue($firstNonexistent);
     $gitHubDriver->getComposerInformation($identifier);
 }
开发者ID:songhongyu,项目名称:idaiyan,代码行数:41,代码来源:GitHubDriverTest.php

示例3: package_index

 /**
  * Get the package index instance
  *
  * We need to construct the instance manually, because there's no way to select
  * a particular instance using $composer->getRepositoryManager()
  *
  * @return ComposerRepository
  */
 private function package_index()
 {
     static $package_index;
     if (!$package_index) {
         $config = new Config();
         $config->merge(array('config' => array('secure-http' => true, 'home' => dirname($this->get_composer_json_path()))));
         $config->setConfigSource(new JsonConfigSource($this->get_composer_json()));
         try {
             $package_index = new ComposerRepository(array('url' => self::PACKAGE_INDEX_URL), new NullIO(), $config);
         } catch (Exception $e) {
             WP_CLI::error($e->getMessage());
         }
     }
     return $package_index;
 }
开发者ID:wp-cli,项目名称:wp-cli,代码行数:23,代码来源:package.php

示例4: createConfig

 /**
  * @param  IOInterface|null $io
  * @return Config
  */
 public static function createConfig(IOInterface $io = null, $cwd = null)
 {
     $cwd = $cwd ?: getcwd();
     $config = new Config(true, $cwd);
     // determine and add main dirs to the config
     $home = self::getHomeDir();
     $config->merge(array('config' => array('home' => $home, 'cache-dir' => self::getCacheDir($home), 'data-dir' => self::getDataDir($home))));
     // Protect directory against web access. Since HOME could be
     // the www-data's user home and be web-accessible it is a
     // potential security risk
     $dirs = array($config->get('home'), $config->get('cache-dir'), $config->get('data-dir'));
     foreach ($dirs as $dir) {
         if (!file_exists($dir . '/.htaccess')) {
             if (!is_dir($dir)) {
                 Silencer::call('mkdir', $dir, 0777, true);
             }
             Silencer::call('file_put_contents', $dir . '/.htaccess', 'Deny from all');
         }
     }
     // load global config
     $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));
     // load global auth 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));
     // load COMPOSER_AUTH environment variable if set
     if ($composerAuthEnv = getenv('COMPOSER_AUTH')) {
         $authData = json_decode($composerAuthEnv, true);
         if (is_null($authData)) {
             throw new \UnexpectedValueException('COMPOSER_AUTH environment variable is malformed, should be a valid JSON object');
         }
         if ($io && $io->isDebug()) {
             $io->writeError('Loading auth config from COMPOSER_AUTH');
         }
         $config->merge(array('config' => $authData));
     }
     return $config;
 }
开发者ID:tommygoud,项目名称:composer,代码行数:54,代码来源:Factory.php

示例5: createConfig

 /**
  * @param IOInterface|null $io
  * @return Config
  */
 public static function createConfig(IOInterface $io = null, $cwd = null)
 {
     $cwd = $cwd ?: getcwd();
     // determine home and cache dirs
     $home = self::getHomeDir();
     $cacheDir = self::getCacheDir($home);
     $dataDir = self::getDataDir($home);
     // Protect directory against web access. Since HOME could be
     // the www-data's user home and be web-accessible it is a
     // potential security risk
     foreach (array($home, $cacheDir, $dataDir) 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);
     // add dirs to the config
     $config->merge(array('config' => array('home' => $home, 'cache-dir' => $cacheDir, 'data-dir' => $dataDir)));
     // load global config
     $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));
     // load global auth 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;
 }
开发者ID:ntoniazzi,项目名称:composer,代码行数:45,代码来源:Factory.php

示例6: createConfig

 /**
  * @return Config
  */
 public static function createConfig()
 {
     // determine home and cache dirs
     $home = getenv('COMPOSER_HOME');
     $cacheDir = getenv('COMPOSER_CACHE_DIR');
     if (!$home) {
         if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
             if (!getenv('APPDATA')) {
                 throw new \RuntimeException('The APPDATA or COMPOSER_HOME environment variable must be set for composer to run correctly');
             }
             $home = strtr(getenv('APPDATA'), '\\', '/') . '/Composer';
         } else {
             if (!getenv('HOME')) {
                 throw new \RuntimeException('The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly');
             }
             $home = rtrim(getenv('HOME'), '/') . '/.composer';
         }
     }
     if (!$cacheDir) {
         if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
             if ($cacheDir = getenv('LOCALAPPDATA')) {
                 $cacheDir .= '/Composer';
             } else {
                 $cacheDir = getenv('APPDATA') . '/Composer/cache';
             }
             $cacheDir = strtr($cacheDir, '\\', '/');
         } else {
             $cacheDir = $home . '/cache';
         }
     }
     // Protect directory against web access. Since HOME could be
     // the www-data's user home and be web-accessible it is a
     // potential security risk
     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();
     // add dirs to the config
     $config->merge(array('config' => array('home' => $home, 'cache-dir' => $cacheDir)));
     $file = new JsonFile($home . '/config.json');
     if ($file->exists()) {
         $config->merge($file->read());
     }
     $config->setConfigSource(new JsonConfigSource($file));
     // move old cache dirs to the new locations
     $legacyPaths = array('cache-repo-dir' => array('/cache' => '/http*', '/cache.svn' => '/*', '/cache.github' => '/*'), 'cache-vcs-dir' => array('/cache.git' => '/*', '/cache.hg' => '/*'), 'cache-files-dir' => array('/cache.files' => '/*'));
     foreach ($legacyPaths as $key => $oldPaths) {
         foreach ($oldPaths as $oldPath => $match) {
             $dir = $config->get($key);
             if ('/cache.github' === $oldPath) {
                 $dir .= '/github.com';
             }
             $oldPath = $config->get('home') . $oldPath;
             $oldPathMatch = $oldPath . $match;
             if (is_dir($oldPath) && $dir !== $oldPath) {
                 if (!is_dir($dir)) {
                     if (!@mkdir($dir, 0777, true)) {
                         continue;
                     }
                 }
                 if (is_array($children = glob($oldPathMatch))) {
                     foreach ($children as $child) {
                         @rename($child, $dir . '/' . basename($child));
                     }
                 }
                 @rmdir($oldPath);
             }
         }
     }
     return $config;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:79,代码来源:Factory.php

示例7: package_index

 /**
  * Get the package index instance
  *
  * We need to construct the instance manually, because there's no way to select
  * a particular instance using $composer->getRepositoryManager()
  *
  * @return ComposerRepository
  */
 private function package_index()
 {
     static $package_index;
     if (!$package_index) {
         $config = new Config();
         $config->merge(array('config' => array('home' => dirname($this->get_composer_json_path()))));
         $config->setConfigSource(new JsonConfigSource($this->get_composer_json()));
         $package_index = new ComposerRepository(array('url' => self::PACKAGE_INDEX_URL), new NullIO(), $config);
     }
     return $package_index;
 }
开发者ID:anver,项目名称:wp-cli,代码行数:19,代码来源:package.php


注:本文中的Composer\Config::setConfigSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。