本文整理汇总了PHP中Composer\IO\IOInterface类的典型用法代码示例。如果您正苦于以下问题:PHP IOInterface类的具体用法?PHP IOInterface怎么用?PHP IOInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IOInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: configure
/**
* @param IOInterface $io
* @param Composer $composer
*
* @return Composer
*/
public static function configure(IOInterface $io, Composer $composer)
{
if (true === $composer->isUndefined()) {
$answer = $io->ask(HookQuestions::COMPOSER_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER);
$composer = $composer->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));
}
return $composer;
}
开发者ID:bruli,项目名称:php-git-hooks,代码行数:14,代码来源:ComposerConfigurator.php
示例14: configure
/**
* @param IOInterface $io
* @param CommitMsg $commitMsg
*
* @return CommitMsg
*/
public static function configure(IOInterface $io, CommitMsg $commitMsg)
{
$answer = $io->ask(HookQuestions::COMMIT_MSG_HOOK, HookQuestions::DEFAULT_TOOL_ANSWER);
$commitMsg = $commitMsg->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));
if (true === $commitMsg->isEnabled()) {
$regularExpressionAnswer = $io->ask(HookQuestions::COMMIT_MSG_REGULAR_EXPRESSION, HookQuestions::COMMIT_MSG_REGULAR_EXPRESSION_ANSWER);
$commitMsg = $commitMsg->addRegularExpression(new RegularExpression($regularExpressionAnswer));
}
return $commitMsg;
}
开发者ID:bruli,项目名称:php-git-hooks,代码行数:16,代码来源:CommitMsgConfigurator.php
示例15: createPluginConfig
/**
* Copy the /config/recaptcha.default.php file from plugin to /config/recaptcha.php
* file in root app. Copy only if the file does not exists.
*
* @param string $dir The application's root directory.
* @param string $pluginDir The plugin's directory.
* @param \Composer\IO\IOInterface $io IO interface to write to console.
* @return void
*/
public static function createPluginConfig($dir, $pluginDir, $io)
{
// copy the file
$pluginConfig = $dir . '/config/recaptcha.php';
$pluginDefaultConfig = $pluginDir . '/config/recaptcha.default.php';
if (!file_exists($pluginConfig)) {
copy($pluginDefaultConfig, $pluginConfig);
$io->write('Created `config/recaptcha.php` file');
}
}
开发者ID:cake17,项目名称:cakephp-recaptcha,代码行数:19,代码来源:Installer.php
示例16: activate
public function activate(Composer $composer, IOInterface $io)
{
$io->write("<info>[ComposerSharedInstaller]</info> activate");
// remove library installer
$manager = $composer->getInstallationManager();
$libraryInstaller = $manager->getInstaller('library');
$manager->removeInstaller($libraryInstaller);
// add shared installer
$installer = new Installer($io, $composer);
$manager->addInstaller($installer);
}
开发者ID:ngyuki,项目名称:composer-shared-installer,代码行数:11,代码来源:Plugin.php
示例17: configure
/**
* @param IOInterface $io
* @param PhpMd $phpMd
*
* @return PhpMd
*/
public static function configure(IOInterface $io, PhpMd $phpMd)
{
if (true === $phpMd->isUndefined()) {
$answer = $io->ask(HookQuestions::PHPMD_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER);
$phpMd = $phpMd->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));
$optionsAnswer = $io->ask(HookQuestions::PHPMD_OPTIONS, null);
$options = new PhpMdOptions($optionsAnswer);
$phpMd = $phpMd->setOptions($options);
}
return $phpMd;
}
开发者ID:bruli,项目名称:php-git-hooks,代码行数:17,代码来源:PhpMdConfigurator.php
示例18: __construct
public function __construct(array $repoConfig, IOInterface $io, Config $config, EventDispatcher $dispatcher = null, array $drivers = null)
{
parent::__construct();
$this->drivers = $drivers ?: array('github' => 'Composer\\Repository\\Vcs\\GitHubDriver', 'gitlab' => 'Composer\\Repository\\Vcs\\GitLabDriver', 'git-bitbucket' => 'Composer\\Repository\\Vcs\\GitBitbucketDriver', 'git' => 'Composer\\Repository\\Vcs\\GitDriver', 'hg-bitbucket' => 'Composer\\Repository\\Vcs\\HgBitbucketDriver', 'hg' => 'Composer\\Repository\\Vcs\\HgDriver', 'perforce' => 'Composer\\Repository\\Vcs\\PerforceDriver', 'fossil' => 'Composer\\Repository\\Vcs\\FossilDriver', 'svn' => 'Composer\\Repository\\Vcs\\SvnDriver');
$this->url = $repoConfig['url'];
$this->io = $io;
$this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
$this->verbose = $io->isVeryVerbose();
$this->config = $config;
$this->repoConfig = $repoConfig;
}
开发者ID:neon64,项目名称:composer,代码行数:11,代码来源:VcsRepository.php
示例19: configure
public static function configure(IOInterface $input, PrePush $prePush)
{
$answer = $input->ask(HookQuestions::PRE_PUSH_HOOK_QUESTION, HookQuestions::DEFAULT_TOOL_ANSWER);
$prePush = $prePush->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));
if (true === $prePush->isEnabled()) {
$rightMessageAnswer = $input->ask(HookQuestions::PRE_PUSH_RIGHT_MESSAGE, HookQuestions::PRE_PUSH_RIGHT_MESSAGE_DEFAULT);
$errorMessageAnswer = $input->ask(HookQuestions::PRE_PUSH_ERROR_MESSAGE, HookQuestions::PRE_PUSH_ERROR_MESSAGE_DEFAULT);
$prePush = $prePush->setMessages(new Messages(new Message($rightMessageAnswer), new Message($errorMessageAnswer)));
}
return $prePush;
}
开发者ID:bruli,项目名称:php-git-hooks,代码行数:11,代码来源:PrePushConfigurator.php
示例20: 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
注:本文中的Composer\IO\IOInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论