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


PHP IO\IOInterface类代码示例

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


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

示例1: createMap

 /**
  * Iterate over all files in the given directory searching for classes.
  *
  * @param \Iterator|string         $path      The path to search in or an iterator
  * @param string                   $whitelist Regex that matches against the file path
  * @param \Composer\IO\IOInterface $io
  *
  * @throws \RuntimeException When the path is neither an existing file nor directory
  *
  * @return array A class map array
  */
 public static function createMap($path, $whitelist = null, IOInterface $io = null)
 {
     if (is_string($path)) {
         if (is_file($path)) {
             $path = array(new \SplFileInfo($path));
         } elseif (is_dir($path)) {
             $path = Finder::create()->files()->followLinks()->name('/\\.(' . implode('|', self::$extensions) . ')$/')->in($path);
         } else {
             throw new \RuntimeException('Could not scan for classes inside "' . $path . '" which does not appear to be a file nor a folder');
         }
     }
     $map = array();
     /** @var \Symfony\Component\Finder\SplFileInfo $file */
     foreach ($path as $file) {
         $filePath = $file->getRealPath();
         if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), self::$extensions)) {
             continue;
         }
         if ($whitelist && !preg_match($whitelist, strtr($filePath, '\\', '/'))) {
             continue;
         }
         $classes = self::findClasses($filePath);
         foreach ($classes as $class) {
             if (!isset($map[$class])) {
                 $map[$class] = $filePath;
             } elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture)s?/}i', strtr($map[$class] . ' ' . $filePath, '\\', '/'))) {
                 $io->write('<warning>Warning: Ambiguous class resolution, "' . $class . '"' . ' was found in both "' . $map[$class] . '" and "' . $filePath . '", the first will be used.</warning>');
             }
         }
     }
     return $map;
 }
开发者ID:bangpound,项目名称:drupal-bridge,代码行数:43,代码来源:ClassMapGenerator.php

示例2: setFolderPermissions

 /**
  * Set globally writable permissions on the "tmp" and "logs" directory.
  *
  * This is not the most secure default, but it gets people up and running quickly.
  *
  * @param string $dir The application's root directory.
  * @param \Composer\IO\IOInterface $io IO interface to write to console.
  * @return void
  */
 public static function setFolderPermissions($dir, $io)
 {
     // Change the permissions on a path and output the results.
     $changePerms = function ($path, $perms, $io) {
         // Get current permissions in decimal format so we can bitmask it.
         $currentPerms = octdec(substr(sprintf('%o', fileperms($path)), -4));
         if (($currentPerms & $perms) == $perms) {
             return;
         }
         $res = chmod($path, $currentPerms | $perms);
         if ($res) {
             $io->write('Permissions set on ' . $path);
         } else {
             $io->write('Failed to set permissions on ' . $path);
         }
     };
     $walker = function ($dir, $perms, $io) use(&$walker, $changePerms) {
         $files = array_diff(scandir($dir), ['.', '..']);
         foreach ($files as $file) {
             $path = $dir . '/' . $file;
             if (!is_dir($path)) {
                 continue;
             }
             $changePerms($path, $perms, $io);
             $walker($path, $perms, $io);
         }
     };
     $worldWritable = bindec('0000000111');
     $walker($dir . '/tmp', $worldWritable, $io);
     $changePerms($dir . '/tmp', $worldWritable, $io);
     $changePerms($dir . '/logs', $worldWritable, $io);
 }
开发者ID:alt3,项目名称:cakebox-console,代码行数:41,代码来源:Installer.php

示例3: selectPackage

 protected function selectPackage(IOInterface $io, $packageName, $version = null)
 {
     $io->writeError('<info>Searching for the specified package.</info>');
     if ($composer = $this->getComposer(false)) {
         $localRepo = $composer->getRepositoryManager()->getLocalRepository();
         $repos = new CompositeRepository(array_merge(array($localRepo), $composer->getRepositoryManager()->getRepositories()));
     } else {
         $defaultRepos = Factory::createDefaultRepositories($this->getIO());
         $io->writeError('No composer.json found in the current directory, searching packages from ' . implode(', ', array_keys($defaultRepos)));
         $repos = new CompositeRepository($defaultRepos);
     }
     $pool = new Pool();
     $pool->addRepository($repos);
     $parser = new VersionParser();
     $constraint = $version ? $parser->parseConstraints($version) : null;
     $packages = $pool->whatProvides($packageName, $constraint, true);
     if (count($packages) > 1) {
         $package = reset($packages);
         $io->writeError('<info>Found multiple matches, selected ' . $package->getPrettyString() . '.</info>');
         $io->writeError('Alternatives were ' . implode(', ', array_map(function ($p) {
             return $p->getPrettyString();
         }, $packages)) . '.');
         $io->writeError('<comment>Please use a more specific constraint to pick a different package.</comment>');
     } elseif ($packages) {
         $package = reset($packages);
         $io->writeError('<info>Found an exact match ' . $package->getPrettyString() . '.</info>');
     } else {
         $io->writeError('<error>Could not find a package matching ' . $packageName . '.</error>');
         return false;
     }
     return $package;
 }
开发者ID:Flesh192,项目名称:magento,代码行数:32,代码来源:ArchiveCommand.php

示例4: download

 /**
  * @static
  *
  * @param \Composer\IO\IOInterface $io
  * @param string                   $destination
  *
  * @return bool
  */
 private static function download(\Composer\IO\IOInterface $io, $destination)
 {
     $io->write('<info>Installing jackrabbit</info>');
     if (false === ($urls = self::getDownloadUrl())) {
         $io->write('Invalid URLs');
     } else {
         reset($urls);
         $r = new RemoteFilesystem($io);
         do {
             try {
                 $url = current($urls);
                 $file = $destination . '/' . basename(parse_url($url, PHP_URL_PATH));
                 $io->write(sprintf('Retrieving Jackrabbit from "%s"', $url), true);
                 $result = $r->copy('', $url, $file, true);
             } catch (\Composer\Downloader\TransportException $ex) {
                 $io->write('', true);
                 $result = false;
                 $file = null;
             }
         } while (false === $result && next($urls));
         if (is_null($file)) {
             throw new \Exception('Invalid file name');
         }
         return $file;
     }
     return false;
 }
开发者ID:Cohros,项目名称:KnowledgeBase,代码行数:35,代码来源:JackrabbitInstaller.php

示例5: createMap

 /**
  * Iterate over all files in the given directory searching for classes
  *
  * @param \Iterator|string $path      The path to search in or an iterator
  * @param string           $blacklist Regex that matches against the file path that exclude from the classmap.
  * @param IOInterface      $io        IO object
  * @param string           $namespace Optional namespace prefix to filter by
  *
  * @throws \RuntimeException When the path is neither an existing file nor directory
  * @return array             A class map array
  */
 public static function createMap($path, $blacklist = null, IOInterface $io = null, $namespace = null)
 {
     if (is_string($path)) {
         if (is_file($path)) {
             $path = array(new \SplFileInfo($path));
         } elseif (is_dir($path)) {
             $path = Finder::create()->files()->followLinks()->name('/\\.(php|inc|hh)$/')->in($path);
         } else {
             throw new \RuntimeException('Could not scan for classes inside "' . $path . '" which does not appear to be a file nor a folder');
         }
     }
     $map = array();
     foreach ($path as $file) {
         $filePath = $file->getRealPath();
         if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), array('php', 'inc', 'hh'))) {
             continue;
         }
         if ($blacklist && preg_match($blacklist, strtr($filePath, '\\', '/'))) {
             continue;
         }
         $classes = self::findClasses($filePath);
         foreach ($classes as $class) {
             // skip classes not within the given namespace prefix
             if (null !== $namespace && 0 !== strpos($class, $namespace)) {
                 continue;
             }
             if (!isset($map[$class])) {
                 $map[$class] = $filePath;
             } elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($map[$class] . ' ' . $filePath, '\\', '/'))) {
                 $io->writeError('<warning>Warning: Ambiguous class resolution, "' . $class . '"' . ' was found in both "' . $map[$class] . '" and "' . $filePath . '", the first will be used.</warning>');
             }
         }
     }
     return $map;
 }
开发者ID:alcaeus,项目名称:composer,代码行数:46,代码来源:ClassMapGenerator.php

示例6: installDependencies

 private static function installDependencies(IOInterface $io, $folder)
 {
     $io->write("[0;32mInstalling front end dependencies from package.json[0m");
     $proc = new ProcessExecutor();
     $proc->execute('cd ' . $folder . ' && npm install');
     $io->write("[0;32mFront end dependencies installed[0m");
 }
开发者ID:studionone,项目名称:Flint,代码行数:7,代码来源:NpmBridge.php

示例7: updateMainConfig

 /**
  * Update the main config
  *
  * @param IOInterface $io
  * @param string      $projectName
  * @param string      $configuredAppPath
  */
 private static function updateMainConfig(IOInterface $io, $projectName, $configuredAppPath)
 {
     $replacements = ["#> session_name <#" => $projectName . "_session", "#> project_name <#" => $projectName];
     $io->write(["<fg=cyan>Updating the main configuration</fg=cyan>", "The installer is now updating your main configuration according to your project name.", "You can change everything later by manually editing <fg=yellow>{$configuredAppPath}/config/config.yml</fg=yellow>.", "", "The following settings are updated:", "-> <fg=yellow>framework.session.name</fg=yellow>: {$replacements['#> session_name <#']}", "-> <fg=yellow>monolog.handlers.swift</fg=yellow> (prod): Plus address and mail subject to: {$replacements['#> project_name <#']}"]);
     self::replaceInAppFile("config/config.yml", $replacements);
     self::replaceInAppFile("config/config_prod.yml", $replacements);
 }
开发者ID:Gemineye,项目名称:BecklynSymfonyEdition,代码行数:14,代码来源:Composer.php

示例8: activate

 /**
  * @inheritdoc
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $this->io = $io;
     //Extend download manager
     $dm = $composer->getDownloadManager();
     $executor = new ProcessExecutor($io);
     $fs = new Filesystem($executor);
     $config = $composer->getConfig();
     $dm->setDownloader('svn-export', new Downloader($io, $config, $executor, $fs));
     //Extend RepositoryManager Classes
     $rm = $composer->getRepositoryManager();
     $rm->setRepositoryClass('svn-export', 'LinearSoft\\Composer\\SvnExport\\Repository\\VcsRepository');
     $rm->setRepositoryClass('svn-export-composer', 'LinearSoft\\Composer\\SvnExport\\Repository\\ComposerRepository');
     //Load Extra Data
     $extra = $composer->getPackage()->getExtra();
     if (isset($extra['svn-export-repositories']) && is_array($extra['svn-export-repositories'])) {
         foreach ($extra['svn-export-repositories'] as $index => $repoConfig) {
             $this->validateRepositories($index, $repoConfig);
             if (isset($repoConfig['name'])) {
                 $name = $repoConfig['name'];
             } else {
                 $name = is_int($index) ? preg_replace('{^https?://}i', '', $repoConfig['url']) : $index;
             }
             if ($repoConfig['type'] === 'svn') {
                 $repoConfig['type'] = 'svn-export';
             } else {
                 $repoConfig['type'] = 'svn-export-composer';
             }
             $repo = $rm->createRepository($repoConfig['type'], $repoConfig);
             $rm->addRepository($repo);
             $this->io->write("Added SvnExport repo: {$name}");
         }
     }
 }
开发者ID:linearsoft,项目名称:composer-svn-export,代码行数:37,代码来源:Plugin.php

示例9: 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

示例10: activate

 /**
  * Just add the \ComposerSymlinker\LocalInstaller new installer
  *
  * @param \Composer\Composer $composer
  * @param \Composer\IO\IOInterface $io
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     if (!empty(getenv('DISABLE_SYMLINKER'))) {
         $io->write('Found DISABLE_SYMLINKER envvar, disabling symlinker...');
         return;
     }
     $composer->getInstallationManager()->addInstaller(new LocalInstaller($io, $composer));
 }
开发者ID:socialengine,项目名称:composer-symlinker,代码行数:14,代码来源:SymlinkerPlugin.php

示例11: __construct

 public function __construct(array $repoConfig, IOInterface $io, Config $config = null, array $drivers = null)
 {
     $this->drivers = $drivers ?: array('github' => 'Composer\\Repository\\Vcs\\GitHubDriver', 'git-bitbucket' => 'Composer\\Repository\\Vcs\\GitBitbucketDriver', 'git' => 'Composer\\Repository\\Vcs\\GitDriver', 'svn' => 'Composer\\Repository\\Vcs\\SvnDriver', 'hg-bitbucket' => 'Composer\\Repository\\Vcs\\HgBitbucketDriver', 'hg' => 'Composer\\Repository\\Vcs\\HgDriver');
     $this->url = $repoConfig['url'];
     $this->io = $io;
     $this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
     $this->verbose = $io->isVerbose();
 }
开发者ID:nlegoff,项目名称:composer,代码行数:8,代码来源:VcsRepository.php

示例12: configure

 /**
  * @param IOInterface $io
  * @param PhpLint     $phpLint
  *
  * @return PhpLint
  */
 public static function configure(IOInterface $io, PhpLint $phpLint)
 {
     if (true === $phpLint->isUndefined()) {
         $answer = $io->ask(HookQuestions::PHPLINT_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER);
         $phpLint = $phpLint->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));
     }
     return $phpLint;
 }
开发者ID:bruli,项目名称:php-git-hooks,代码行数:14,代码来源:PhpLintConfigurator.php

示例13: setAssetsVersion

 /**
  * @param array $parameters
  * @param array $options
  *
  * @return bool
  */
 public function setAssetsVersion(array &$parameters, array $options)
 {
     $assetsVersion = null;
     $assetsVersionExists = false;
     $assetsVersionStrategy = null;
     $assetsVersionStrategyExists = false;
     if (array_key_exists(self::ASSETS_VERSION, $parameters)) {
         $assetsVersion = $parameters[self::ASSETS_VERSION];
         $assetsVersionExists = true;
     }
     if (array_key_exists(self::ASSETS_VERSION_STRATEGY, $parameters)) {
         $assetsVersionStrategy = $parameters[self::ASSETS_VERSION_STRATEGY];
         $assetsVersionStrategyExists = true;
     }
     $hasChanges = false;
     if (!$assetsVersionExists || !$this->isEnvironmentVariable($options, self::ASSETS_VERSION)) {
         $assetsVersion = $this->generateAssetsVersion($assetsVersionStrategy, $assetsVersion);
         if (!$assetsVersionExists || null !== $assetsVersion) {
             $hasChanges = true;
             $this->io->write(sprintf('<info>Updating the "%s" parameter</info>', self::ASSETS_VERSION));
             $parameters[self::ASSETS_VERSION] = $assetsVersion;
         }
     }
     if (!$assetsVersionStrategyExists) {
         $hasChanges = true;
         $this->io->write(sprintf('<info>Initializing the "%s" parameter</info>', self::ASSETS_VERSION_STRATEGY));
         $parameters[self::ASSETS_VERSION_STRATEGY] = $assetsVersionStrategy;
     }
     return $hasChanges;
 }
开发者ID:ramunasd,项目名称:platform,代码行数:36,代码来源:AssetsVersionHandler.php

示例14: publish

 /**
  * @param string $targetPath
  * @param string $installPath
  * @param array $map
  * @param bool $isSymlink
  * @param bool $isRelative
  *
  * @throws IOException
  * @throws \InvalidArgumentException
  *
  * @api
  *
  * @quality:method [B]
  */
 public function publish($targetPath, $installPath, array $map, $isSymlink, $isRelative)
 {
     $targetPath = rtrim($targetPath, '/');
     $installPath = rtrim($installPath, '/');
     $this->filesystem->mkdir($targetPath, 0777);
     foreach ($map as $from => $to) {
         $targetDir = realpath($targetPath) . '/' . $to;
         $sourceDir = realpath($installPath) . '/' . $from;
         $this->filesystem->remove($targetDir);
         if ($isSymlink) {
             $this->io->write(sprintf('Trying to install AdminLTE %s assets as symbolic links.', $from));
             $originDir = $sourceDir;
             if ($isRelative) {
                 $originDir = $this->filesystem->makePathRelative($sourceDir, realpath($targetPath));
             }
             try {
                 $this->filesystem->symlink($originDir, $targetDir);
                 $this->io->write(sprintf('The AdminLTE %s assets were installed using symbolic links.', $from));
             } catch (IOException $e) {
                 $this->hardCopy($sourceDir, $targetDir);
                 $this->io->write(sprintf('It looks like your system doesn\'t support symbolic links,
                     so the AdminLTE %s assets were installed by copying them.', $from));
             }
         } else {
             $this->io->write(sprintf('Installing AdminLTE %s assets as <comment>hard copies</comment>.', $from));
             $this->hardCopy($sourceDir, $targetDir);
         }
     }
 }
开发者ID:kamilsk,项目名称:common,代码行数:43,代码来源:Processor.php

示例15: process

 public function process(Config\Template $tmpl)
 {
     /* process template if condition is not set or condition is valid */
     if ($tmpl->getCondition() == null || $this->conditionValidator->isValid($tmpl->getCondition(), $this->vars)) {
         /* load source file */
         if (is_file($tmpl->getSource())) {
             $content = file_get_contents($tmpl->getSource());
             /* replace all vars by values */
             if (is_array($this->vars)) {
                 foreach ($this->vars as $key => $value) {
                     $content = str_replace('${' . $key . '}', $value, $content);
                 }
             }
             /* save destination file */
             if (is_file($tmpl->getDestination()) && !$tmpl->isCanRewrite()) {
                 $this->io->write(__CLASS__ . ": <comment>Destination file '{$tmpl->getDestination()}' is already exist and cannot be rewrote (rewrite = false).</comment>");
             } else {
                 $this->fileSaver->save($tmpl->getDestination(), $content);
                 $this->io->write(__CLASS__ . ": <info>Destination file '{$tmpl->getDestination()}' is created from source template '{$tmpl->getSource()}'.</info>");
             }
         } else {
             $this->io->writeError(__CLASS__ . ": <error>Cannot open source template ({$tmpl->getSource()}).</error>");
         }
     } else {
         /* there is wrong condition for template */
         $outSrc = $tmpl->getSource();
         $cond = $tmpl->getCondition();
         $outCond = '${' . $cond->getVar() . '}' . $cond->getOperation() . $cond->getValue();
         $this->io->write(__CLASS__ . ": <comment>Skip processing of the template ({$outSrc}) because condition ({$outCond}) is 'false'.</comment>");
     }
 }
开发者ID:praxigento,项目名称:composer_plugin_templates,代码行数:31,代码来源:Handler.php


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