當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Event::getIO方法代碼示例

本文整理匯總了PHP中Composer\Script\Event::getIO方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::getIO方法的具體用法?PHP Event::getIO怎麽用?PHP Event::getIO使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Composer\Script\Event的用法示例。


在下文中一共展示了Event::getIO方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: install

 /**
  * @return int
  */
 public function install()
 {
     $io = $this->event->getIO();
     $composer = $this->event->getComposer();
     $repository = new PhantomJSVersionRepository($io, $composer);
     $versions = $repository->getVersions();
     if (!count($versions)) {
         $io->write('<error>Could not found any version.</error>');
         return 1;
     }
     $binDir = $composer->getConfig()->get('bin-dir');
     is_dir($binDir) ?: mkdir($binDir, 0755, true);
     $binDir = realpath($binDir);
     $vendorDir = $composer->getConfig()->get('vendor-dir') . '/sgc-fireball/phantomjs';
     is_dir($vendorDir) ?: mkdir($vendorDir, 0755, true);
     $vendorDir = realpath($vendorDir);
     $downloader = new PhantomJSDownloader($io, $composer);
     foreach ($versions as $version) {
         try {
             $package = $downloader->createComposerPackage($version, $vendorDir);
             if ($downloader->download($package)) {
                 copy($vendorDir . '/bin/phantomjs', $binDir . '/phantomjs');
                 chmod($binDir . '/phantomjs', 0755);
                 return 0;
             }
         } catch (\Exception $e) {
         }
     }
     $io->write(sprintf('<error>Could not download %s.</error>', $package->getDistUrl()));
     return 2;
 }
開發者ID:sgc-fireball,項目名稱:selenium-server-standalone-installer,代碼行數:34,代碼來源:Installer.php

示例2: createRequiredFiles

 public static function createRequiredFiles(Event $event)
 {
     $fs = new Filesystem();
     $root = static::getDrupalRoot(getcwd());
     $dirs = ['modules', 'profiles', 'themes'];
     // Required for unit testing
     foreach ($dirs as $dir) {
         if (!$fs->exists($root . '/' . $dir)) {
             $fs->mkdir($root . '/' . $dir);
             $fs->touch($root . '/' . $dir . '/.gitkeep');
         }
     }
     // Prepare the settings file for installation
     if (!$fs->exists($root . '/sites/default/settings.php')) {
         $fs->copy($root . '/sites/default/default.settings.php', $root . '/sites/default/settings.php');
         $fs->chmod($root . '/sites/default/settings.php', 0666);
         $event->getIO()->write("Create a sites/default/settings.php file with chmod 0666");
     }
     // Prepare the services file for installation
     if (!$fs->exists($root . '/sites/default/services.yml')) {
         $fs->copy($root . '/sites/default/default.services.yml', $root . '/sites/default/services.yml');
         $fs->chmod($root . '/sites/default/services.yml', 0666);
         $event->getIO()->write("Create a sites/default/services.yml file with chmod 0666");
     }
     // Create the files directory with chmod 0777
     if (!$fs->exists($root . '/sites/default/files')) {
         $oldmask = umask(0);
         $fs->mkdir($root . '/sites/default/files', 0777);
         umask($oldmask);
         $event->getIO()->write("Create a sites/default/files directory with chmod 0777");
     }
 }
開發者ID:openrestaurant,項目名稱:openrestaurant-project,代碼行數:32,代碼來源:ScriptHandler.php

示例3: install

 /**
  * Installs the shop files.
  *
  * @param \Composer\Script\Event $event Event instance
  * @throws \RuntimeException If an error occured
  */
 public static function install(\Composer\Script\Event $event)
 {
     $repository = $event->getComposer()->getRepositoryManager();
     $t3package = $repository->findPackage('aimeos/aimeos-typo3', '*');
     if ($t3package !== null) {
         $installer = $event->getComposer()->getInstallationManager();
         $t3path = $installer->getInstallPath($t3package);
         if (($package = $repository->findPackage('aimeos/ai-client-html', '*')) !== null) {
             $event->getIO()->write('Installing Aimeos public files from HTML client');
             $path = $installer->getInstallPath($package);
             self::copyRecursive($path . '/client/html/themes', $t3path . '/Resources/Public/Themes');
         }
         if (($package = $repository->findPackage('aimeos/ai-admin-extadm', '*')) !== null) {
             $event->getIO()->write('Installing Aimeos public files from ExtJS admin');
             $path = $installer->getInstallPath($package);
             self::copyRecursive($path . '/admin/extjs/resources', $t3path . '/Resources/Public/Admin/extjs/resources');
             self::copyRecursive($path . '/admin/extjs/lib/ext.ux/Portal/resources', $t3path . '/Resources/Public/Admin/extjs/lib/ext.ux/Portal');
             self::copyRecursive($path . '/admin/extjs/lib/ext.ux/AdvancedSearch/resources', $t3path . '/Resources/Public/Admin/extjs/lib/ext.ux/AdvancedSearch');
         }
         if (file_exists($t3path . '/Resources/Private/Extensions') === false && ($package = $repository->findPackage('aimeos/ai-typo3', '*')) !== null) {
             $event->getIO()->write('Creating symlink to Aimeos extension directory');
             $path = dirname($installer->getInstallPath($package));
             symlink(getcwd() . '/' . $path, $t3path . '/Resources/Private/Extensions');
         }
     }
 }
開發者ID:aimeos,項目名稱:aimeos-typo3,代碼行數:32,代碼來源:Composer.php

示例4: migrateSettingsFile

 public static function migrateSettingsFile(Event $event = null)
 {
     if ($event !== null) {
         $event->getIO()->write("Migrating old setting file...");
     }
     if ($event) {
         $root_dir = realpath('');
     } else {
         $root_dir = realpath('../../');
     }
     if (file_exists($root_dir . '/app/config/parameters.yml')) {
         return false;
     }
     if (file_exists($root_dir . '/' . self::SETTINGS_FILE)) {
         $tmp_settings = file_get_contents($root_dir . '/' . self::SETTINGS_FILE);
         if (strpos($tmp_settings, '_DB_SERVER_') !== false) {
             $tmp_settings = preg_replace('/(\'|")\\_/', '$1_LEGACY_', $tmp_settings);
             file_put_contents($root_dir . '/' . self::SETTINGS_FILE, $tmp_settings);
             include $root_dir . '/' . self::SETTINGS_FILE;
             $factory = new RandomLib\Factory();
             $generator = $factory->getLowStrengthGenerator();
             $secret = $generator->generateString(56);
             $default_parameters = Yaml::parse($root_dir . '/app/config/parameters.yml.dist');
             $parameters = array('parameters' => array('database_host' => _LEGACY_DB_SERVER_, 'database_port' => '~', 'database_user' => _LEGACY_DB_USER_, 'database_password' => _LEGACY_DB_PASSWD_, 'database_name' => _LEGACY_DB_NAME_, 'database_prefix' => _LEGACY_DB_PREFIX_, 'database_engine' => _LEGACY_MYSQL_ENGINE_, 'cookie_key' => _LEGACY_COOKIE_KEY_, 'cookie_iv' => _LEGACY_COOKIE_IV_, 'ps_caching' => _LEGACY_PS_CACHING_SYSTEM_, 'ps_cache_enable' => _LEGACY_PS_CACHE_ENABLED_, 'ps_creation_date' => _LEGACY_PS_CREATION_DATE_, 'secret' => $secret, 'mailer_transport' => 'smtp', 'mailer_host' => '127.0.0.1', 'mailer_user' => '~', 'mailer_password' => '~') + $default_parameters['parameters']);
             if (file_put_contents($root_dir . '/app/config/parameters.yml', Yaml::dump($parameters))) {
                 $settings_content = "<?php\n";
                 $settings_content .= "//@deprecated 1.7";
                 file_put_contents($root_dir . '/' . self::SETTINGS_FILE, $settings_content);
             }
         }
     }
     if ($event !== null) {
         $event->getIO()->write("Finished...");
     }
 }
開發者ID:M03G,項目名稱:PrestaShop,代碼行數:35,代碼來源:Migrate.php

示例5: addPhpCsToPreCommitHook

 public static function addPhpCsToPreCommitHook(Event $event)
 {
     $extra = $event->getComposer()->getPackage()->getExtra();
     $dependencyToResolve = self::arrayResolvePath("codesniffer:standard:dependency", $extra);
     if (is_null($dependencyToResolve)) {
         $event->getIO()->writeError("Cannot install pre-commit hooks. No CodeSniffer standard configured at extra->codesniffer->standard.");
         return;
     }
     if (is_array($dependencyToResolve)) {
         $event->getIO()->writeError("Cannot install pre-commit hooks. Configuration of extra->codesniffer->standard->dependency is invalid.");
         return;
     }
     $originFile = getcwd() . '/.git/hooks/pre-commit';
     if (!is_dir(dirname($originFile))) {
         mkdir(dirname($originFile), 0777, true);
     }
     $templateContent = file_get_contents(__DIR__ . '/templates/git/hooks/pre-commit-phpcs');
     $originContent = '';
     if (file_exists($originFile)) {
         $originContent = file_get_contents($originFile);
     }
     if (strpos($originContent, '# BEGIN:metasyntactical/composer-codesniffer-hooks') !== false) {
         return;
     }
     $newContent = $originContent;
     if (mb_strlen($originContent)) {
         $newContent .= "\n";
     }
     $newContent .= str_replace(array("{STANDARDPATH}"), array($event->getComposer()->getConfig()->get("vendor-dir", Config::RELATIVE_PATHS) . "/{$dependencyToResolve}/ruleset.xml"), $templateContent);
     file_put_contents($originFile, $newContent);
     $perms = fileperms($originFile);
     chmod($originFile, $perms | 0x40 | 0x8 | 0x1);
     clearstatcache(null, $originFile);
 }
開發者ID:metasyntactical,項目名稱:composer-codesniffer-hooks,代碼行數:34,代碼來源:ScriptHandler.php

示例6: postInstall

 public static function postInstall(Event $event)
 {
     $vendor_dir = $event->getComposer()->getConfig()->get('vendor-dir');
     if (is_dir($vendor_dir . '/codeigniter/framework/application')) {
         exec("rm -R {$vendor_dir}/codeigniter/framework/application {$vendor_dir}/codeigniter/framework/user_guide && rm {$vendor_dir}/codeigniter/framework/*.*");
         $event->getIO()->write("Codeigniter installation cleaned");
     }
     if (is_dir($vendor_dir . '/google/apiclient/examples')) {
         exec("rm -R {$vendor_dir}/google/apiclient/examples {$vendor_dir}/google/apiclient/style {$vendor_dir}/google/apiclient/tests && rm {$vendor_dir}/google/apiclient/*.*");
         $event->getIO()->write("Google Api Client cleaned");
     }
 }
開發者ID:NaszvadiG,項目名稱:ci-starter,代碼行數:12,代碼來源:Package.php

示例7: postCreateProject

 /**
  * Callback for the Composer post-create-project-command event
  *
  * @param Event $event
  */
 public static function postCreateProject(Event $event)
 {
     $io = $event->getIO();
     $install = new Install();
     $install->run($event->getIO(), new Questions\InstallQuestions());
     echo 'Cleaning up' . PHP_EOL;
     // Remove the source code.
     self::delTree('src');
     echo 'Script finished. Your site is ready!' . PHP_EOL;
     // exit composer and terminate installation process
     exit;
 }
開發者ID:humanmade,項目名稱:wp-maestro,代碼行數:17,代碼來源:ScriptHandler.php

示例8: updateDirs

 public static function updateDirs(Event $event)
 {
     $extra = $event->getComposer()->getPackage()->getExtra();
     if (isset($extra['update-config-dirs'])) {
         $configDir = static::createConfigFileUpdate($event->getIO());
         foreach ($extra['update-config-dirs'] as $dist => $target) {
             $configDir->updateDir($target, $dist);
         }
     } else {
         $event->getIO()->write('<warning>Composer configuration is missing: {"extra": "update-config-dirs": {"path/to/dist/dir": "path/to/target/dir"}}</warning>');
     }
 }
開發者ID:wemakecustom,項目名稱:composer-script-utils,代碼行數:12,代碼來源:ScriptHandler.php

示例9: install

 private static function install(Event $event)
 {
     if (!$event->isDevMode()) {
         return;
     }
     $manager = new GitHookManager();
     if ($manager->isInstalled() || $manager->install()) {
         $event->getIO()->write('Pre-commit hook has been successfully installed.');
     } else {
         $event->getIO()->writeError('Some errors occurred during the installation process. Pre-commit hook are NOT installed.');
     }
 }
開發者ID:redco,項目名稱:redcode-precommit,代碼行數:12,代碼來源:ComposerListener.php

示例10: executeCommand

 /**
  * Executes a command.
  *
  * @param string $cmd
  * @param Event  $event
  *
  * @throws \RuntimeException
  */
 private static function executeCommand($cmd, Event $event)
 {
     $phpFinder = new PhpExecutableFinder();
     if (false === ($phpPath = $phpFinder->find())) {
         throw new \RuntimeException('The php executable could not be found.');
     }
     $process = new Process(sprintf('%s app/console%s %s', $phpPath, $event->getIO()->isDecorated() ? ' --ansi' : '', $cmd));
     $process->run(function ($type, $buffer) use($event) {
         $event->getIO()->write($buffer, false);
     });
     if (!$process->isSuccessful()) {
         throw new \RuntimeException(sprintf('An error occurred while executing the "%s" command.', $cmd));
     }
 }
開發者ID:qzminski,項目名稱:contao-core-bundle,代碼行數:22,代碼來源:ScriptHandler.php

示例11: getFile

 /**
  * @param Event $event
  * @param       $filename
  * @param       $s3key
  * @throws \Exception
  */
 protected static function getFile(Event $event, $filename, $s3key)
 {
     $env = getenv('SYRUP_ENV');
     if (!$env) {
         $env = $event->isDevMode() ? 'dev' : 'prod';
     }
     if (!in_array($env, ['dev', 'test', 'prod'])) {
         throw new \Exception('SYRUP_ENV only accepts value "dev", "test" or "prod"');
     }
     if ($env == 'dev') {
         if ($event->getIO()->isInteractive()) {
             $event->getIO()->askAndValidate("<comment>Get <question>{$filename}</question> from development S3 bucket? [<options=bold>y</options=bold>/n/s]:\ny - yes <info>(default)</info>\nn - no <info>(manually input folder containing the file)</info>\ns - skip <info>(keep current file)</info>\n</comment>", function ($answer) use($event, $s3key, $filename, $env) {
                 switch ($answer) {
                     case "y":
                         self::getFromS3($event->getIO(), $s3key, self::PARAMETERS_DIR . $filename, $env);
                         break;
                     case "n":
                         self::getFromIO($event->getIO(), $filename);
                         break;
                     case "s":
                         break;
                     default:
                         throw new \InvalidArgumentException("Invalid option! Please choose either y, n or s");
                 }
             }, 3, "y");
         } elseif (file_exists("./{$filename}") && $event->getIO()->askConfirmation("Use './{$filename}'? [<options=bold>y</options=bold>/n]", true)) {
             self::getFromIO($event->getIO(), $filename, ".");
         } else {
             self::getFromS3($event->getIO(), $s3key, self::PARAMETERS_DIR . $filename, $env);
         }
     } else {
         self::getFromS3($event->getIO(), $s3key, self::PARAMETERS_DIR . $filename, $env);
     }
 }
開發者ID:keboola,項目名稱:syrup,代碼行數:40,代碼來源:ScriptHandler.php

示例12: setup

 public static function setup(Event $event)
 {
     $composer = $event->getComposer();
     $installer = new self($event->getIO(), $composer, 'tiki-theme');
     $composer->getInstallationManager()->addInstaller($installer);
     $composer->getEventDispatcher()->addSubscriber($installer);
 }
開發者ID:rjsmelo,項目名稱:tiki,代碼行數:7,代碼來源:ThemeInstaller.php

示例13: executeCommand

 protected static function executeCommand(Event $event, $consoleDir, $cmd, $timeout = 300)
 {
     $php = escapeshellarg(static::getPhp(false));
     $phpArgs = implode(' ', array_map('escapeshellarg', static::getPhpArguments()));
     $console = escapeshellarg($consoleDir . '/console');
     if ($event->getIO()->isDecorated()) {
         $console .= ' --ansi';
     }
     $process = new Process($php . ($phpArgs ? ' ' . $phpArgs : '') . ' ' . $console . ' ' . $cmd, null, null, null, $timeout);
     $process->run(function ($type, $buffer) use($event) {
         $event->getIO()->write($buffer, false);
     });
     if (!$process->isSuccessful()) {
         throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command.', escapeshellarg($cmd)));
     }
 }
開發者ID:shivas,項目名稱:versioning-bundle,代碼行數:16,代碼來源:ScriptHandler.php

示例14: publish

 /**
  * @param Event $event
  *
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  * @throws \Symfony\Component\Filesystem\Exception\IOException
  *
  * @api
  *
  * @quality:method [C]
  */
 public static function publish(Event $event)
 {
     $composer = $event->getComposer();
     $extras = $composer->getPackage()->getExtra();
     if (!isset($extras['admin-lte'])) {
         throw new \InvalidArgumentException('The AdminLTE installer needs to be configured through the extra.admin-lte setting.');
     }
     $config = $extras['admin-lte'];
     if (!isset($config['target'])) {
         throw new \InvalidArgumentException('The extra.admin-lte must contains target path.');
     }
     $package = $composer->getRepositoryManager()->getLocalRepository()->findPackage('almasaeed2010/adminlte', '~2.0');
     if ($package === null) {
         throw new \RuntimeException('The AdminLTE package not found.');
     }
     $forPublishing = ['dist' => 'adminlte'];
     if (!empty($config['bootstrap'])) {
         $forPublishing['bootstrap'] = 'adminlte-bootstrap';
     }
     if (!empty($config['plugins'])) {
         $forPublishing['plugins'] = 'adminlte-plugins';
     }
     if (!empty($config['demo'])) {
         $forPublishing[''] = 'adminlte-demo';
     }
     (new Processor(new Filesystem(), $event->getIO()))->publish($config['target'], $composer->getInstallationManager()->getInstallPath($package), $forPublishing, !empty($config['symlink']), !empty($config['relative']));
 }
開發者ID:kamilsk,項目名稱:common,代碼行數:38,代碼來源:Publisher.php

示例15: update

 /**
  * Update the stored database.
  *
  * @since 0.1.0
  *
  * @param Event $event The event that has called the update method.
  */
 public static function update(Event $event)
 {
     $dbFilename = PHPReleases::getLocation();
     self::maybeCreateDBFolder(dirname($dbFilename));
     $io = $event->getIO();
     $io->write('Fetching change logs from official PHP website...', false);
     $io->write(' PHP5...', false);
     $php5 = self::downloadFile(self::PHP_5_RELEASES);
     $io->write(' PHP7...', false);
     $php7 = self::downloadFile(self::PHP_7_RELEASES);
     $io->write(' done!', true);
     $releases = array();
     $io->write('Parsing change logs to extract versions...', false);
     $io->write(' PHP5...', false);
     $php5Releases = self::parseReleases($php5);
     $io->write('(' . count($php5Releases) . ' releases)', false);
     $releases = array_merge($releases, $php5Releases);
     $io->write(' PHP7...', false);
     $php7Releases = self::parseReleases($php7);
     $io->write('(' . count($php7Releases) . ' releases)', false);
     $releases = array_merge($releases, $php7Releases);
     $io->write(' done!', true);
     ksort($releases, SORT_NATURAL);
     self::generateConfig($releases, $dbFilename);
     $io->write('The PHP Releases database has been updated.', true);
 }
開發者ID:brightnucleus,項目名稱:php-releases,代碼行數:33,代碼來源:PHPReleases_Plugin.php


注:本文中的Composer\Script\Event::getIO方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。