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


PHP Composer\Config类代码示例

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


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

示例1: build

 public function build($rootDirectory, $optimize = false, $noDevMode = false)
 {
     $packages = $this->loadPackages($rootDirectory);
     $evm = new EventDispatcher(new Composer(), $this->io);
     $generator = new AutoloadGenerator($evm, $this->io);
     $generator->setDevMode(!$noDevMode);
     $installationManager = new InstallationManager();
     $installationManager->addInstaller(new FiddlerInstaller());
     $this->io->write('Building fiddler.json projects.');
     foreach ($packages as $packageName => $config) {
         if (strpos($packageName, 'vendor') === 0) {
             continue;
         }
         $this->io->write(' [Build] <info>' . $packageName . '</info>');
         $mainPackage = new Package($packageName, "@stable", "@stable");
         $mainPackage->setType('fiddler');
         $mainPackage->setAutoload($config['autoload']);
         $mainPackage->setDevAutoload($config['autoload-dev']);
         $localRepo = new FiddlerInstalledRepository();
         $this->resolvePackageDependencies($localRepo, $packages, $packageName);
         $composerConfig = new Config(true, $rootDirectory);
         $composerConfig->merge(array('config' => array('vendor-dir' => $config['path'] . '/vendor')));
         $generator->dump($composerConfig, $localRepo, $mainPackage, $installationManager, 'composer', $optimize);
     }
 }
开发者ID:sidisinsane,项目名称:fiddler,代码行数:25,代码来源:Build.php

示例2: 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;
 }
开发者ID:bamarni,项目名称:composition,代码行数:43,代码来源:Composition.php

示例3: __construct

 /**
  * @param string $url
  * @param string $destination
  * @param bool $useRedirector
  * @param IO\IOInterface $io
  * @param Config $config
  */
 public function __construct($url, $destination, $useRedirector, IO\IOInterface $io, Config $config)
 {
     $this->setURL($url);
     $this->setDestination($destination);
     $this->setCA($config->get('capath'), $config->get('cafile'));
     $this->setupAuthentication($io, $useRedirector, $config->get('github-domains') ?: array(), $config->get('gitlab-domains') ?: array());
 }
开发者ID:hirak,项目名称:prestissimo,代码行数:14,代码来源:CopyRequest.php

示例4: loadConfiguration

 /**
  * {@inheritDoc}
  */
 public function loadConfiguration(Config $config)
 {
     $bitbucketOauth = $config->get('bitbucket-oauth') ?: array();
     $githubOauth = $config->get('github-oauth') ?: array();
     $gitlabOauth = $config->get('gitlab-oauth') ?: array();
     $httpBasic = $config->get('http-basic') ?: array();
     // reload oauth tokens from config if available
     foreach ($bitbucketOauth as $domain => $cred) {
         $this->checkAndSetAuthentication($domain, $cred['consumer-key'], $cred['consumer-secret']);
     }
     foreach ($githubOauth as $domain => $token) {
         if (!preg_match('{^[a-z0-9]+$}', $token)) {
             throw new \UnexpectedValueException('Your github oauth token for ' . $domain . ' contains invalid characters: "' . $token . '"');
         }
         $this->checkAndSetAuthentication($domain, $token, 'x-oauth-basic');
     }
     foreach ($gitlabOauth as $domain => $token) {
         $this->checkAndSetAuthentication($domain, $token, 'oauth2');
     }
     // reload http basic credentials from config if available
     foreach ($httpBasic as $domain => $cred) {
         $this->checkAndSetAuthentication($domain, $cred['username'], $cred['password']);
     }
     // setup process timeout
     ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
 }
开发者ID:neon64,项目名称:composer,代码行数:29,代码来源:BaseIO.php

示例5: loadConfiguration

 /**
  * {@inheritDoc}
  */
 public function loadConfiguration(Config $config)
 {
     // reload oauth token from config if available
     if ($tokens = $config->get('github-oauth')) {
         foreach ($tokens as $domain => $token) {
             if (!preg_match('{^[a-z0-9]+$}', $token)) {
                 throw new \UnexpectedValueException('Your github oauth token for ' . $domain . ' contains invalid characters: "' . $token . '"');
             }
             $this->setAuthentication($domain, $token, 'x-oauth-basic');
         }
     }
     if ($tokens = $config->get('gitlab-oauth')) {
         foreach ($tokens as $domain => $token) {
             $this->setAuthentication($domain, $token, 'oauth2');
         }
     }
     // reload http basic credentials from config if available
     if ($creds = $config->get('http-basic')) {
         foreach ($creds as $domain => $cred) {
             $this->setAuthentication($domain, $cred['username'], $cred['password']);
         }
     }
     // setup process timeout
     ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
 }
开发者ID:alancleaver,项目名称:composer,代码行数:28,代码来源:BaseIO.php

示例6: 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');
    }
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:26,代码来源:AbstractAssetsRepositoryTest.php

示例7: setUp

 protected function setUp()
 {
     $this->fs = new Filesystem();
     $that = $this;
     $this->workingDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'cmptest-' . md5(uniqid('', true));
     $this->fs->ensureDirectoryExists($this->workingDir);
     $this->vendorDir = $this->workingDir . DIRECTORY_SEPARATOR . 'composer-test-autoload';
     $this->ensureDirectoryExistsAndClear($this->vendorDir);
     $this->config = $this->getMock('Composer\\Config');
     $this->configValueMap = array('vendor-dir' => function () use($that) {
         return $that->vendorDir;
     });
     $this->config->expects($this->atLeastOnce())->method('get')->will($this->returnCallback(function ($arg) use($that) {
         $ret = null;
         if (isset($that->configValueMap[$arg])) {
             $ret = $that->configValueMap[$arg];
             if (is_callable($ret)) {
                 $ret = $ret();
             }
         }
         return $ret;
     }));
     $this->origDir = getcwd();
     chdir($this->workingDir);
     $this->im = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock();
     $this->im->expects($this->any())->method('getInstallPath')->will($this->returnCallback(function ($package) use($that) {
         $targetDir = $package->getTargetDir();
         return $that->vendorDir . '/' . $package->getName() . ($targetDir ? '/' . $targetDir : '');
     }));
     $this->repository = $this->getMock('Composer\\Repository\\InstalledRepositoryInterface');
     $this->eventDispatcher = $this->getMockBuilder('Composer\\EventDispatcher\\EventDispatcher')->disableOriginalConstructor()->getMock();
     $this->generator = new AutoloadGenerator($this->eventDispatcher);
 }
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-composer,代码行数:33,代码来源:AutoloadGeneratorTest.php

示例8: getConfig

 protected function getConfig()
 {
     $config = new Config();
     $settings = array('config' => array('home' => $this->testPath));
     $config->merge($settings);
     return $config;
 }
开发者ID:neon64,项目名称:composer,代码行数:7,代码来源:PerforceDownloaderTest.php

示例9: 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')));
 }
开发者ID:MvegaR,项目名称:ingSotfware,代码行数:25,代码来源:BowerInstallerTest.php

示例10: __construct

 public function __construct(SVNRepositoryConfig $repoConfig, IOInterface $io, Config $config)
 {
     // @TODO: add event dispatcher?
     $this->repoConfig = $repoConfig;
     $this->plugin = $repoConfig->getPlugin();
     // check url immediately - can't do anything without it
     $urls = [];
     foreach ((array) $repoConfig->get('url') as $url) {
         if (($urlParts = parse_url($url)) === false || empty($urlParts['scheme'])) {
             continue;
         }
         // untrailingslashit
         $urls[] = rtrim($url, '/');
     }
     if (!count($urls)) {
         throw new \UnexpectedValueException('No valid URLs for SVN repository: ' . print_r($repoConfig->get('url'), true));
     }
     $repoConfig->set('url', $urls);
     // use the cache TTL from the config?
     if ($repoConfig->get('cache-ttl') === 'config') {
         $repoConfig->set('cache-ttl', $config->get('cache-files-ttl'));
     }
     $this->io = $io;
     $this->cache = new Cache($io, $config->get('cache-repo-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', reset($urls)));
     $this->loader = new ArrayLoader();
     // clear out stale cache
     $this->cache->gc($repoConfig->get('cache-ttl'), $config->get('cache-files-maxsize'));
     $this->vendors = $repoConfig->get('vendors');
     $this->defaultVendor = key($this->vendors);
     // create an SvnUtil to execute commands
     $this->svnUtil = new SvnUtil($io, $repoConfig->get('trust-cert'));
 }
开发者ID:balbuf,项目名称:composer-wp,代码行数:32,代码来源:SVNRepository.php

示例11: getHttpGetRequest

 /**
  * @param string $origin domain text
  * @param string $url
  * @param IO\IOInterface $io
  * @param CConfig $config
  * @param array $pluginConfig
  * @return Aspects\HttpGetRequest
  */
 public static function getHttpGetRequest($origin, $url, IO\IOInterface $io, CConfig $config, array $pluginConfig)
 {
     if (substr($origin, -10) === 'github.com') {
         $origin = 'github.com';
         $requestClass = 'GitHub';
     } elseif (in_array($origin, $config->get('github-domains') ?: array())) {
         $requestClass = 'GitHub';
     } elseif (in_array($origin, $config->get('gitlab-domains') ?: array())) {
         $requestClass = 'GitLab';
     } else {
         $requestClass = 'HttpGet';
     }
     $requestClass = __NAMESPACE__ . '\\Aspects\\' . $requestClass . 'Request';
     $request = new $requestClass($origin, $url, $io);
     $request->verbose = $pluginConfig['verbose'];
     if ($pluginConfig['insecure']) {
         $request->curlOpts[CURLOPT_SSL_VERIFYPEER] = false;
     }
     if (!empty($pluginConfig['capath'])) {
         $request->curlOpts[CURLOPT_CAPATH] = $pluginConfig['capath'];
     }
     if (!empty($pluginConfig['userAgent'])) {
         $request->curlOpts[CURLOPT_USERAGENT] = $pluginConfig['userAgent'];
     }
     return $request;
 }
开发者ID:k0pernikus,项目名称:prestissimo,代码行数:34,代码来源:Factory.php

示例12: scan

 /**
  * @return string[]
  */
 public function scan()
 {
     $parameters = ['command' => 'dump-autoload', '--no-interaction' => true, '--working-dir' => $this->directory, '--optimize' => true, '--no-dev' => true];
     $this->createComposerApplication()->run(new ArrayInput($parameters), $this->output);
     $config = new Config(true, $this->directory);
     return require $config->get('vendor-dir') . '/composer/autoload_classmap.php';
 }
开发者ID:renanbr,项目名称:phpact,代码行数:10,代码来源:UnitScanner.php

示例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;
 }
开发者ID:tenside,项目名称:core-bundle,代码行数:36,代码来源:PackageControllerTest.php

示例14: __construct

 public function __construct(array $repoConfig, IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null)
 {
     if (!preg_match('{^[\\w.]+\\??://}', $repoConfig['url'])) {
         // assume http as the default protocol
         $repoConfig['url'] = 'http://' . $repoConfig['url'];
     }
     $repoConfig['url'] = rtrim($repoConfig['url'], '/');
     if ('https?' === substr($repoConfig['url'], 0, 6)) {
         $repoConfig['url'] = (extension_loaded('openssl') ? 'https' : 'http') . substr($repoConfig['url'], 6);
     }
     $urlBits = parse_url($repoConfig['url']);
     if ($urlBits === false || empty($urlBits['scheme'])) {
         throw new \UnexpectedValueException('Invalid url given for Composer repository: ' . $repoConfig['url']);
     }
     if (!isset($repoConfig['options'])) {
         $repoConfig['options'] = array();
     }
     if (isset($repoConfig['allow_ssl_downgrade']) && true === $repoConfig['allow_ssl_downgrade']) {
         $this->allowSslDowngrade = true;
     }
     $this->config = $config;
     $this->options = $repoConfig['options'];
     $this->url = $repoConfig['url'];
     $this->baseUrl = rtrim(preg_replace('{^(.*)(?:/packages.json)?(?:[?#].*)?$}', '$1', $this->url), '/');
     $this->io = $io;
     $this->cache = new Cache($io, $config->get('cache-repo-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url), 'a-z0-9.$');
     $this->loader = new ArrayLoader();
     $this->rfs = new RemoteFilesystem($this->io, $this->config, $this->options);
     $this->eventDispatcher = $eventDispatcher;
 }
开发者ID:aminembarki,项目名称:composer,代码行数:30,代码来源:ComposerRepository.php

示例15: fetchAllFromOperations

 /**
  * @param IO\IOInterface $io
  * @param Config $config
  * @param Operation\OperationInterface[] $ops
  */
 public function fetchAllFromOperations(IO\IOInterface $io, Config $config, array $ops)
 {
     $cachedir = rtrim($config->get('cache-files-dir'), '\\/');
     $requests = array();
     foreach ($ops as $op) {
         switch ($op->getJobType()) {
             case 'install':
                 $p = $op->getPackage();
                 break;
             case 'update':
                 $p = $op->getTargetPackage();
                 break;
             default:
                 continue 2;
         }
         $url = $this->getUrlFromPackage($p);
         if (!$url) {
             continue;
         }
         $destination = $cachedir . DIRECTORY_SEPARATOR . FileDownloaderDummy::getCacheKeyCompat($p, $url);
         if (file_exists($destination)) {
             continue;
         }
         $useRedirector = (bool) preg_match('%^(?:https|git)://github\\.com%', $p->getSourceUrl());
         try {
             $request = new CopyRequest($url, $destination, $useRedirector, $io, $config);
             $requests[] = $request;
         } catch (FetchException $e) {
             // do nothing
         }
     }
     if (count($requests) > 0) {
         $this->fetchAll($io, $requests);
     }
 }
开发者ID:hirak,项目名称:prestissimo,代码行数:40,代码来源:Prefetcher.php


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