The callback receives the type of output (out or err) and
some bytes from the output in real-time. It allows to have feedback
from the independent process during execution.
The STDOUT and STDERR are also available after the process is finished
via the getOutput() and getErrorOutput() methods.
/** * @return string */ public function compile() { $this->stopwatch->start('webpack.total'); $this->stopwatch->start('webpack.prepare'); // Recompile twig templates where its needed. $this->addSplitPoints(); $this->addResolveConfig(); // Write the webpack configuration file. file_put_contents($this->cache_dir . DIRECTORY_SEPARATOR . 'webpack.config.js', $this->generator->getConfiguration()); $this->profiler->set('compiler.performance.prepare', $this->stopwatch->stop('webpack.prepare')->getDuration()); $this->stopwatch->start('webpack.compiler'); $this->process->run(); $output = $this->process->getOutput() . $this->process->getErrorOutput(); $this->profiler->set('compiler.executed', true); $this->profiler->set('compiler.successful', strpos($output, 'Error:') === false); $this->profiler->set('compiler.last_output', $output); if ($this->profiler->get('compiler.successful')) { $this->tracker->rebuild(); } // Finally, write some logging for later use. file_put_contents($this->cache_dir . DIRECTORY_SEPARATOR . 'webpack.compiler.log', $output); $this->profiler->set('compiler.performance.compiler', $this->stopwatch->stop('webpack.compiler')->getDuration()); $this->profiler->set('compiler.performance.total', $this->stopwatch->stop('webpack.total')->getDuration()); return $output; }
/** * Runs behat command with provided parameters * * @When /^I run "behat(?: ([^"]*))?"$/ * * @param string $argumentsString */ public function iRunBehat($argumentsString = '') { $argumentsString = strtr($argumentsString, array('\'' => '"')); $this->process->setWorkingDirectory($this->workingDir); $this->process->setCommandLine(sprintf('%s %s %s %s', $this->phpBin, escapeshellarg(BEHAT_BIN_PATH), $argumentsString, strtr('--format-settings=\'{"timer": false}\'', array('\'' => '"', '"' => '\\"')))); $this->process->run(); }
protected function execute(InputInterface $input, OutputInterface $output) { $this->downloadConfiguration(); $library = new GLibc(); try { $this->download()->extract(); $library->setEnv($this->env)->setProjectDir($this->baseDir)->initialize()->boot($input, $output); $configure = $this->projectDir . '/' . $library->configure(); $this->projectDir = dirname($this->projectDir) . '/glibc-build'; $this->fs->mkdir($this->projectDir); $this->output->write(' Building : '); $process = new Process($configure, $this->projectDir, $this->env->toArray()); $process->setTimeout(0); $process->run(); if ($process->isSuccessful()) { $process->setCommandLine('make -j4 && make -j4 install'); $process->run(); } if ($process->isSuccessful()) { $message = '<info>✔</info>'; } else { $message = '<error>✕</error>'; } $this->output->writeln($message); } catch (\Exception $e) { $this->cleanUp(); throw $e; } $this->createConfiguration(); $this->output->writeln(sprintf(" <info>%s</info> Droidphp Installer <info>successfully configured</info> Now you can:\n" . " * Run :\n" . " 1. Execute the <comment>%s build:components</comment> command.\n" . " To Build the project\n\n", defined('PHP_WINDOWS_VERSION_BUILD') ? 'OK' : '✔', basename($_SERVER['PHP_SELF']))); }
protected function execute(InputInterface $input, OutputInterface $output) { $env = array('APP_INCLUDE' => $this->getContainer()->getParameter('bcc_resque.resque.vendor_dir') . '/autoload.php', 'VVERBOSE' => 1, 'QUEUE' => $input->getArgument('queues')); $workerCommand = 'php ' . $this->getContainer()->getParameter('bcc_resque.resque.vendor_dir') . '/chrisboulton/php-resque/resque.php'; if (!$input->getOption('foreground')) { $workerCommand = 'nohup ' . $workerCommand . ' > ' . $this->getContainer()->getParameter('kernel.logs_dir') . '/resque.log 2>&1 & echo $!'; } $process = new Process($workerCommand, null, $env); $output->writeln(\sprintf('Starting worker <info>%s</info>', $process->getCommandLine())); // if foreground, we redirect output if ($input->getOption('foreground')) { $process->run(function ($type, $buffer) use($output) { $output->write($buffer); }); } else { $process->run(); $pid = \trim($process->getOutput()); if (function_exists('gethostname')) { $hostname = gethostname(); } else { $hostname = php_uname('n'); } $output->writeln(\sprintf('<info>Worker started</info> %s:%s:%s', $hostname, $pid, $input->getArgument('queues'))); } }
/** * Executes a shell command. * * @param string $command * * @return $this */ public function runShellCommand($command) { $this->process = new Process($command); $this->exitCode = $this->process->run(); $this->stdOutput = $this->process->getOutput(); $this->stdError = $this->process->getErrorOutput(); return $this; }
/** * @When I run :command * @When I run :command on :server */ public function iRun($command, $server = 'default') { if (!isset($this->config[$server])) { throw new \Exception(sprintf('Configuration not found for server "%s"', $server)); } $this->process = $this->createProcess($command, $this->config[$server]); $this->process->run(); }
/** * Run a command as a process. * * @param string $command * @return self */ public function run($command) { $this->command = escapeshellcmd($command); $this->process->setCommandLine($this->command); $this->process->run(); $this->validateRun(); return $this; }
/** * Executes the backup command. */ public function archive() { $this->process->setCommandLine($this->getCommand()); $this->process->run(); if ($this->process->getErrorOutput()) { throw new \RuntimeException($this->process->getErrorOutput()); } }
/** * @param $command * @throws ShellProcessFailed * @throws \Symfony\Component\Process\Exception\LogicException */ public function process($command) { if (empty($command)) { return; } $this->process->setCommandLine($command); $this->process->run(); if (!$this->process->isSuccessful()) { throw new ShellProcessFailed($this->process->getErrorOutput()); } }
/** * Runs the command, returns the proc after it's done * * @param array $options * @param callable $callback * * @return Process */ public function execute($options = array(), $callback = null) { $cmd = $this->buildCommand($options); $env = defined('PHP_WINDOWS_VERSION_BUILD') ? Habitat::getAll() : null; $proc = new Process($cmd, null, $env, null, $timeout = 600); if (!is_callable($callback)) { $proc->run(); } else { $proc->run($callback); } return $proc; }
protected function execute(InputInterface $input, OutputInterface $output) { $env = array('QUEUE' => $input->getArgument('queues'), 'VERBOSE' => $input->getOption('verbose'), 'COUNT' => $input->getOption('count'), 'INTERVAL' => $input->getOption('interval'), 'PREFIX' => 'resque:'); $redisHost = $this->container->getParameter('packages.resque.host'); $redisPort = $this->container->getParameter('packages.resque.port'); $redisDatabase = $this->container->getParameter('packages.resque.database'); if ($redisHost != null && $redisPort != null) { $backend = strpos($redisHost, 'unix:') === false ? $redisHost . ':' . $redisPort : $redisHost; $env['REDIS_BACKEND'] = $backend; } if (isset($redisDatabase)) { $env['REDIS_BACKEND_DB'] = $redisDatabase; } $opt = ''; if (0 !== ($m = (int) $input->getOption('memory-limit'))) { $opt = sprintf('-d memory_limit=%dM', $m); } $workerCommand = strtr('%bin% %opt% %dir%/bin/resque', array('%bin%' => $this->getPhpBinary(), '%opt%' => $opt, '%dir%' => $this->container->getParameter('app.root_dir'))); if (!$input->getOption('foreground')) { $workerCommand = strtr('nohup %cmd% > %logs_dir%/resque.log 2>&1 & echo $!', array('%cmd%' => $workerCommand, '%logs_dir%' => $this->container->getParameter('app.log_dir'))); } // In windows: When you pass an environment to CMD it replaces the old environment // That means we create a lot of problems with respect to user accounts and missing vars // this is a workaround where we add the vars to the existing environment. if (defined('PHP_WINDOWS_VERSION_BUILD')) { foreach ($env as $key => $value) { putenv($key . "=" . $value); } $env = null; } $process = new Process($workerCommand, null, $env, null, null); if (!$input->getOption('quiet')) { $output->writeln(sprintf('Executing <info>%s</info>...', $process->getCommandLine())); } if ($input->getOption('foreground')) { $process->run(function ($type, $buffer) use($output) { $output->write($buffer); }); } else { $process->run(); if (function_exists('gethostname')) { $hostname = gethostname(); } else { $hostname = php_uname('n'); } if (!$input->getOption('quiet')) { $workers = $env['COUNT']; $output->writeln(sprintf('Starting <info>%s %s</info> on <info>%s</info> for <info>%s</info> queues', $workers, $workers != 1 ? 'workers' : 'worker', $hostname, $input->getArgument('queues'))); } } $output->writeln(''); }
/** * @param Process $process * @param OutputInterface $output */ private function runTests($process, $output) { if ($output->isDebug()) { $process->run(function ($type, $buffer) use($output) { if (Process::ERR === $type) { $output->write('<fg=yellow>' . $buffer . '</fg=yellow>'); } else { $output->write($buffer); } }); } else { $process->run(); } }
protected function executeCommand($command) { $process = new SymfonyProcess($command); $process->setWorkingDirectory($this->workingDirectory); $process->setTimeout(null); if ($this->isPrinted) { $process->run(function ($type, $buffer) { SymfonyProcess::ERR === $type ? print 'ER» ' . $buffer : (print $buffer); }); } else { $process->run(); } return new Result($this, $process->getExitCode(), $process->getOutput()); }
public function execute() { $logger = $this->getRunConfig()->getLogger(); $this->process = new Process($this->command); $logger->info('Start command:' . $this->command); $this->process->setTimeout($this->timeout); $this->process->setWorkingDirectory($this->getRunConfig()->getRepositoryDirectory()); $this->process->run(); $output = trim($this->process->getOutput()); $logger->info($output); if (!$this->process->isSuccessful()) { $logger->emergency($this->process->getErrorOutput()); throw new \RuntimeException('Command not successful:' . $this->command); } }
public function execute(InputInterface $input, OutputInterface $output) { $process = new Process('vagrant destroy --force', realpath(__DIR__ . '/../'), array_merge($_SERVER, $_ENV), null, null); $process->run(function ($type, $line) use($output) { $output->write($line); }); }
public function download($in_dir) { $repo = $in_dir . '/' . $this->package . ".git"; if (is_dir($repo)) { return; } $cmd = 'git clone --mirror %s %s'; $process = new Process(sprintf($cmd, $this->url, $repo)); $process->setTimeout(3600); $process->run(); if (!$process->isSuccessful()) { throw new \Exception($process->getErrorOutput()); } $cmd = 'cd %s && git update-server-info -f'; $process = new Process(sprintf($cmd, $repo)); $process->setTimeout(3600); $process->run(); if (!$process->isSuccessful()) { throw new \Exception($process->getErrorOutput()); } $cmd = 'cd %s && git fsck'; $process = new Process(sprintf($cmd, $repo)); $process->setTimeout(3600); $process->run(); if (!$process->isSuccessful()) { throw new \Exception($process->getErrorOutput()); } }
/** * Create process that lint PHP file. * * @param string $path path to file * * @return Process */ public function createProcessForFile($path) { $process = new Process('php -l ' . ProcessUtils::escapeArgument($path)); $process->setTimeout(null); $process->run(); return $process; }
/** * Compiles the Silex source code into one single Phar file. * * @param string $pharFile Name of the output Phar file */ public function compile($pharFile = 'silex.phar') { if (file_exists($pharFile)) { unlink($pharFile); } $process = new Process('git log --pretty="%h %ci" -n1 HEAD'); if ($process->run() > 0) { throw new \RuntimeException('The git binary cannot be found.'); } $this->version = trim($process->getOutput()); $phar = new \Phar($pharFile, 0, 'silex.phar'); $phar->setSignatureAlgorithm(\Phar::SHA1); $phar->startBuffering(); $finder = new Finder(); $finder->files()->ignoreVCS(true)->name('*.php')->notName('Compiler.php')->in(__DIR__ . '/..')->in(__DIR__ . '/../../vendor/pimple/pimple/lib')->in(__DIR__ . '/../../vendor/symfony/class-loader/Symfony/Component/ClassLoader')->in(__DIR__ . '/../../vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher')->in(__DIR__ . '/../../vendor/symfony/http-foundation/Symfony/Component/HttpFoundation')->in(__DIR__ . '/../../vendor/symfony/http-kernel/Symfony/Component/HttpKernel')->in(__DIR__ . '/../../vendor/symfony/routing/Symfony/Component/Routing')->in(__DIR__ . '/../../vendor/symfony/browser-kit/Symfony/Component/BrowserKit')->in(__DIR__ . '/../../vendor/symfony/css-selector/Symfony/Component/CssSelector')->in(__DIR__ . '/../../vendor/symfony/dom-crawler/Symfony/Component/DomCrawler'); foreach ($finder as $file) { $this->addFile($phar, $file); } $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../LICENSE'), false); $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/.composer/autoload.php')); $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/.composer/ClassLoader.php')); $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/.composer/autoload_namespaces.php')); // Stubs $phar->setStub($this->getStub()); $phar->stopBuffering(); // $phar->compressFiles(\Phar::GZ); unset($phar); }
/** * Execute the command. * * @param InputInterface $input * @param OutputInterface $output */ public function execute(InputInterface $input, OutputInterface $output) { $process = new Process('vagrant up', $_ENV['PUBSTACK_PATH'], array_merge($_SERVER, $_ENV), null, null); $process->run(function ($type, $line) use($output) { $output->write($line); }); }
protected function execute(InputInterface $input, OutputInterface $output) { $container = $this->getApplication()->getContainer(); $commandFile = realpath($_SERVER['SCRIPT_FILENAME']); $currentVersion = "v" . $container->getVersion(); $updateVersion = trim(@file_get_contents('https://raw.githubusercontent.com/kohkimakimoto/altax/master/version')); if (!$container->isPhar()) { $output->writeln('<error>You can not update altax. Because altax only supports self-update command on PHAR file version.</error>'); return 1; } if (!preg_match('/^v[0-9].[0-9]+.[0-9]+$/', $updateVersion)) { $output->writeln('<error>You can not update altax. Because the latest version of altax are not available for download.</error>'); return 1; } if ($currentVersion === $updateVersion) { $output->writeln('<info>You are already using altax version <comment>' . $updateVersion . '</comment>.</info>'); return 0; } $output->writeln(sprintf("Updating to version <info>%s</info>.", $updateVersion)); $tmpDir = "/tmp/" . uniqid("altax.update."); $process = new Process("mkdir {$tmpDir} && cd {$tmpDir} && curl -L https://raw.githubusercontent.com/kohkimakimoto/altax/master/installer.sh | bash -s local {$updateVersion}"); $process->setTimeout(null); if ($process->run() !== 0) { $output->writeln('<error>You can not update altax.'); return 1; } $fs = new Filesystem(); $fs->copy($tmpDir . "/altax.phar", $commandFile, true); $fs->remove($tmpDir); $output->writeln("Done."); }
/** * {@inheritdoc} */ public function run($callback = null) { $event = new Event\GitEvent($this->git, $this, $this->command); $dispatcher = $this->git->getDispatcher(); try { // Throw the "git.command.prepare" event prior to executing. $dispatcher->dispatch(Event\GitEvents::GIT_PREPARE, $event); // Execute command if it is not flagged to be bypassed and throw the // "git.command.success" event, otherwise do not execute the comamnd // and throw the "git.command.bypass" event. if ($this->command->notBypassed()) { parent::run($callback); if ($this->isSuccessful()) { $dispatcher->dispatch(Event\GitEvents::GIT_SUCCESS, $event); } else { $output = $this->getErrorOutput(); if (trim($output) == '') { $output = $this->getOutput(); } throw new \RuntimeException($output); } } else { $dispatcher->dispatch(Event\GitEvents::GIT_BYPASS, $event); } } catch (\RuntimeException $e) { $dispatcher->dispatch(Event\GitEvents::GIT_ERROR, $event); throw new GitException($e->getMessage()); } }
/** * {@inheritDoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $vendorDir = sprintf('%s/../vendor', $this->rootDir); $codeSnifferDir = sprintf('%s/squizlabs/php_codesniffer', $vendorDir); if (false === file_exists($codeSnifferDir)) { $output->writeln('<error>Could not find squizlabs/php_codesniffer. Is it installed?</error>'); } $command = 'git clone git@github.com:florianeckerstorfer/Symfony2-coding-standard.git Symfony2'; $cwd = sprintf('%s/CodeSniffer/Standards', $codeSnifferDir); $update = false; if (true === file_exists(sprintf('%s/Symfony2', $cwd))) { $command = 'git pull origin master'; $cwd = sprintf('%s/Symfony2', $cwd); $update = true; } $process = new Process($command, $cwd); $process->run(function ($type, $buffer) use($input, $output) { if (true === $input->getOption('verbose')) { $output->writeln(sprintf('<comment>%s</comment>', $buffer)); } }); if (false === $process->isSuccessful()) { throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command.', escapeshellarg($command))); } if (true === $update) { $output->writeln('<info>Updated Symfony2 coding standard for PHP_CodeSniffer.</info>'); return; } $output->writeln('<info>Installed Symfony2 coding standard for PHP_CodeSniffer.</info>'); }
private function install(OutputInterface $output, $targetFolder, $symlinkName, $forceDownload, HttpSource $source) { $version = $source->getVersion(); $extractedFolder = 'PhpStorm-' . $version; if (is_dir($targetFolder . '/' . $extractedFolder) && false === $forceDownload) { $output->writeln(sprintf('<comment>Phpstorm <info>%s</info> already exists, skipping download..</comment>', $version)); } else { $output->write(sprintf('<comment>Download %s </comment><info>%s</info><comment>...</comment>', $source->getName(), $version)); $downloadProcess = new Process(sprintf("wget %s -O phpstorm.tar.gz", escapeshellarg($source->getUrl()))); $downloadProcess->setTimeout(3600); $downloadProcess->run(); $output->writeln(' <info>OK</info>'); if (!$downloadProcess->isSuccessful()) { throw new \RuntimeException($downloadProcess->getErrorOutput()); } $output->write('<comment>Extracting...</comment>'); $extractProcess = new Process(sprintf('tar xfz phpstorm.tar.gz; rm phpstorm.tar.gz; mv %1$s %2$s', escapeshellarg($extractedFolder), escapeshellarg($targetFolder))); $extractProcess->run(); $output->writeln(' <info>OK</info>'); if (!$extractProcess->isSuccessful()) { throw new \RuntimeException($extractProcess->getErrorOutput()); } } $output->write('<comment>Linking...</comment>'); $command = sprintf('cd %2$s && ln -s -f -T %1$s %3$s', escapeshellarg($extractedFolder), escapeshellarg($targetFolder), escapeshellarg($symlinkName)); $linkProcess = new Process($command); $linkProcess->run(); $output->writeln(' <info>OK</info>'); if (!$linkProcess->isSuccessful()) { throw new \RuntimeException($linkProcess->getErrorOutput()); } }
protected function dump_base(base $base, InputInterface $input, OutputInterface $output) { $date_obj = new DateTime(); $filename = sprintf('%s%s_%s.sql', p4string::addEndSlash($input->getArgument('directory')), $base->get_dbname(), $date_obj->format('Y_m_d_H_i_s')); $command = sprintf('mysqldump %s %s %s %s %s %s --default-character-set=utf8', '--host=' . escapeshellarg($base->get_host()), '--port=' . escapeshellarg($base->get_port()), '--user='******'--password='******'--databases', escapeshellarg($base->get_dbname())); if ($input->getOption('gzip')) { $filename .= '.gz'; $command .= ' | gzip -9'; } elseif ($input->getOption('bzip')) { $filename .= '.bz2'; $command .= ' | bzip2 -9'; } $output->write(sprintf('Generating <info>%s</info> ... ', $filename)); $command .= ' > ' . escapeshellarg($filename); $process = new Process($command); $process->setTimeout((int) $input->getOption('timeout')); $process->run(); if (!$process->isSuccessful()) { $output->writeln('<error>Failed</error>'); return 1; } if (file_exists($filename) && filesize($filename) > 0) { $output->writeln('OK'); return 0; } else { $output->writeln('<error>Failed</error>'); return 1; } }
protected function execute(InputInterface $input, OutputInterface $output) { # снимаем ограничение времени выполнения скрипта (в safe-mode не работает) set_time_limit(0); $container = $this->getContainer(); $logger = $container->get('vidal.digest_logger'); $em = $container->get('doctrine')->getManager(); # рассылаем с помощью EventSendCommand $command = 'php ' . $container->get('kernel')->getRootDir() . '/console vidal:eventsend '; $doctors = $em->createQuery(' SELECT e.username FROM VidalMainBundle:User e ')->getResult(); $emails = array(); foreach ($doctors as $doctor) { $emails[] = $doctor['username']; } // $emails[] = '*****@*****.**'; $emails = array_diff($emails, $logger->getSentEmails()); for ($i = 0, $c = count($emails); $i < $c; $i = $i + 100) { $emails100 = array_slice($emails, $i, 100); $emails100 = implode(' ', $emails100); # формируем команду для рассылки соточки try { $processCmd = $command . $emails100; $process = new Process($processCmd); $process->run(); } catch (\Exception $e) { continue; } $process = null; sleep(40); } }
protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('<info>Defining crontab task...</info>'); $output->writeln('<info>Please enter the frequency of data aggregating</info> <comment>(frequency must be equal "pinba_stats_history" of the pinba engine config)</comment>.'); $dialog = $this->getHelperSet()->get('dialog'); $frequency = $dialog->askAndValidate($output, 'Frequency (in minutes, default "15"): ', function ($answer) { if (intval($answer) <= 0) { throw new \RunTimeException('You must enter positive integer value'); } return $answer; }, false, '15'); $process = new Process('crontab -l'); $process->setTimeout(20); $process->run(); $crontabString = $process->isSuccessful() ? $process->getOutput() : ''; $path = realpath(__DIR__ . '/../../../console'); $command = '*/' . $frequency . ' * * * * ' . $path . ' aggregate'; if (strpos($crontabString, $command) === false) { $crontabString .= "\n" . $command . "\n"; } $file = tempnam(sys_get_temp_dir(), 'ipm'); file_put_contents($file, $crontabString); $process = new Process('crontab ' . $file); $process->setTimeout(20); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getErrorOutput()); } $output->writeln('<info>Crontab task are defined successfully</info>'); $output->writeln('<info>Please set parameter "aggregation_period" to value "PT' . $frequency . 'M" in config/parameters.yml</info>'); }
public function generate($url, $width, $height, $name) { $hash = md5($url); $thumbnail = new Thumbnail(); $thumbnail->url = $url; $thumbnail->width = $width; $thumbnail->height = $height; $thumbnail->relativePath = $this->compilePattern($width, $height, $name); $thumbnail->absolutePath = $this->documentRoot . '/' . $thumbnail->relativePath; if ($this->fs->exists($thumbnail->absolutePath)) { return $thumbnail; } $tmpFile = $this->cacheDir . '/' . $hash; if (!$this->fs->exists($this->cacheDir)) { $this->fs->mkdir($this->cacheDir); } if (!$this->fs->exists($tmpFile)) { $this->getImageForUrl($url, $tmpFile); } if (!$this->fs->exists(dirname($thumbnail->absolutePath))) { $this->fs->mkdir(dirname($thumbnail->absolutePath)); } $cmd = "convert %s[0] -resize '%dx%d^' -gravity center -crop %dx%d+0+0 +repage %s"; $process = new Process(sprintf($cmd, $tmpFile, $width, $height, $width, $height, $thumbnail->absolutePath)); $process->run(); if (!$process->isSuccessful()) { throw new \Exception($process->getErrorOutput()); } return $thumbnail; }
/** * Compiles composer into a single phar file * * @throws \RuntimeException */ public function compile() { $pharFile = 'refactor.phar'; if (file_exists($pharFile)) { unlink($pharFile); } $process = new Process('git log --pretty="%H" -n1 HEAD', $this->directory); if ($process->run() != 0) { throw new \RuntimeException('Can\'t run git log. You must ensure to run compile from git repository clone and that git binary is available.'); } $this->version = trim($process->getOutput()); $process = new Process('git describe --tags HEAD'); if ($process->run() == 0) { $this->version = trim($process->getOutput()); } $phar = new \Phar($pharFile, 0, 'refactor.phar'); $phar->setSignatureAlgorithm(\Phar::SHA1); $phar->startBuffering(); $finder = new Finder(); $finder->files()->ignoreVCS(true)->name('*.php')->notName('Compiler.php')->in($this->directory . '/src/main'); foreach ($finder as $file) { $this->addFile($phar, $file); } $finder = new Finder(); $finder->files()->ignoreVCS(true)->name('*.php')->exclude('test')->exclude('features')->in($this->directory . '/vendor/'); foreach ($finder as $file) { $this->addFile($phar, $file); } $this->addRefactorBin($phar); // Stubs $phar->setStub($this->getStub()); $phar->stopBuffering(); unset($phar); }
/** * Execute the command. * * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * @return void */ public function execute(InputInterface $input, OutputInterface $output) { $process = new Process('vagrant resume', realpath(__DIR__ . '/../'), $_ENV, null, null); $process->run(function ($type, $line) use($output) { $output->write($line); }); }
/** * @param Process $process * @param OutputInterface $outputInterface * * @return int */ public function executeProcess(Process $process, OutputInterface $outputInterface) { return $process->run(function ($type, $buffer) use($outputInterface) { $type; $outputInterface->write($buffer); }); }