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


PHP Process\Process类代码示例

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


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

示例1: execute

 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[] = 'tulupov.m@gmail.com';
     $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);
     }
 }
开发者ID:Evrika,项目名称:Vidal,代码行数:34,代码来源:EventCommand.php

示例2: execute

 /**
  * 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);
     });
 }
开发者ID:hilenium,项目名称:homestead-symfony2,代码行数:14,代码来源:ResumeCommand.php

示例3: download

 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());
     }
 }
开发者ID:matsinet,项目名称:medusa,代码行数:28,代码来源:Downloader.php

示例4: dump_base

 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=' . escapeshellarg($base->get_user()), '--password=' . escapeshellarg($base->get_passwd()), '--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;
     }
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:29,代码来源:systemBackupDB.php

示例5: __construct

 public function __construct(\Symfony\Component\Process\Process $process)
 {
     $this->process = $process;
     $code = 0;
     $message = '';
     // Not all of the ansible errors have output in stderr. Therefore, if
     // stderr is empty we will use the stdout output instead to get clues
     // on what the actual error was.
     $error = $process->getErrorOutput();
     if (is_null($error)) {
         $error = $process->getOutput();
     }
     // Figure out the specific error that occured
     if (false !== strpos($error, 'the playbook') && false !== strpos($error, 'could not be found')) {
         $code = self::NOT_FOUND;
         $message = self::NOT_FOUND_MSG;
     } else {
         if (false !== strpos($error, 'Syntax Error while loading YAML script')) {
             $code = self::SYNTAX_ERROR;
             $message = self::SYNTAX_ERROR_MSG;
         } else {
             if (false !== strpos($error, 'One or more undefined variables')) {
                 $code = self::UNDEFINED_VARIABLE;
                 $message = self::UNDEFINED_VARIABLE_MSG;
             } else {
                 $code = self::GENERAL_ERROR;
                 $message = self::GENERAL_ERROR_MSG;
             }
         }
     }
     parent::__construct($message, $code);
 }
开发者ID:vladimir-m,项目名称:ansible,代码行数:32,代码来源:PlaybookException.php

示例6: compile

 /**
  * 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);
 }
开发者ID:robo47,项目名称:Silex,代码行数:33,代码来源:Compiler.php

示例7: compile

 /**
  * Compiles composer into a single phar file
  *
  * @throws \RuntimeException
  * @param string $pharFile The full path to the file to create
  */
 public function compile($pharFile = 'composer.phar')
 {
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $process = new Process('git log --pretty="%h" -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, 'composer.phar');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->notName('Compiler.php')->in(__DIR__ . '/..');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->name('*.php')->in(__DIR__ . '/../../vendor/symfony/');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/.composer/ClassLoader.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/.composer/autoload.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/.composer/autoload_namespaces.php'));
     $this->addComposerBin($phar);
     // Stubs
     $phar->setStub($this->getStub());
     $phar->stopBuffering();
     // disabled for interoperability with systems without gzip ext
     // $phar->compressFiles(\Phar::GZ);
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../LICENSE'), false);
     unset($phar);
 }
开发者ID:natxet,项目名称:composer,代码行数:41,代码来源:Compiler.php

示例8: uploadFileAction

 /**
  * @Route("/file-upload", name="uploadFile")
  * @Template()
  */
 public function uploadFileAction(Request $request)
 {
     $allow = $request->get('private', false);
     /** @var File $file */
     $file = $request->files->get('file');
     $imageName = uniqid('legofy-online') . '.png';
     $command = sprintf('legofy %s/%s %s/../../../web/images/%s', $file->getPath(), $file->getFilename(), __DIR__, $imageName);
     $process = new Process($command);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new ProcessFailedException($process);
     }
     $imagine = new Imagine();
     $imageFile = $imagine->open(sprintf('%s/../../../web/images/%s', __DIR__, $imageName));
     $box = $imageFile->getSize();
     if ($box->getHeight() > $box->getWidth()) {
         $imageFile->resize(new Box(400, $box->getHeight() * (400 / $box->getWidth())))->crop(new Point(0, 0), new Box(400, 400));
     } else {
         $newWidth = $box->getWidth() * (400 / $box->getHeight());
         $imageFile->resize(new Box($newWidth, 400))->crop(new Point(($newWidth - 400) / 2, 0), new Box(400, 400));
     }
     $imageFile->save(sprintf('%s/../../../web/images/thumbnails/%s', __DIR__, $imageName));
     $image = new Image();
     $image->setPrivate($allow)->setName($imageName)->setCreationDate(new \DateTime());
     $em = $this->getDoctrine()->getManager();
     $em->persist($image);
     $em->flush();
     return new JsonResponse(['url' => $this->generateUrl('editImage', ['id' => $image->getId(), 'name' => $image->getName()])]);
 }
开发者ID:pCyril,项目名称:php-legofy,代码行数:33,代码来源:DefaultController.php

示例9: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $distribution = $input->getArgument('distribution');
     $version = $input->getArgument('version');
     $download = $this->downloadProject($distribution, $version);
     $process = new Process("tar -xzf {$download['location']} -C /tmp/");
     $process->start();
     if (substr($version, 0, 3) == '7.x') {
         $finder = new Finder();
         $process->wait();
         // Find all modules dropped in to the distribution.
         $finder->files()->name("*.info");
         $filename = array();
         foreach ($finder->in($download['locationUncompressed']) as $file) {
             $filename[] = array('path' => $file->getRealPath(), 'filename' => $file->getFileName());
         }
         // Create the array for the containing modules.
         $return = array();
         foreach ($filename as $file) {
             $contents = $this->parse_info_file(file_get_contents($file['path']));
             $machine_name = substr($file['filename'], 0, strpos($file['filename'], '.'));
             $return[$machine_name] = array('name' => $contents['name'], 'machine_name' => substr($file['filename'], 0, strpos($file['filename'], '.')), 'core' => $contents['core'], 'version' => $contents['version'], 'status' => 'Enabled', 'package' => isset($contents['package']) ? $contents['package'] : null);
         }
         $output->write(json_encode($return));
     }
 }
开发者ID:jkswoods,项目名称:stool,代码行数:26,代码来源:DistributionCommand.php

示例10: testPhpdocIsInstalled

 /**
  *@group cmd
  */
 public function testPhpdocIsInstalled()
 {
     $process = new Process('phpdoc --version');
     $process->run();
     $output = $process->getOutput();
     $this->assertContains("phpDocumentor version", $output);
 }
开发者ID:rasodu,项目名称:DLEMP,代码行数:10,代码来源:PhpDocumentorTest.php

示例11: deserialize

 /**
  * @param string $serialized
  *
  * @return Process
  */
 public function deserialize($serialized)
 {
     $data = json_decode($serialized, true);
     $process = new Process($data['command']);
     $process->setTimeout($data['timeout']);
     return $process;
 }
开发者ID:php-lug,项目名称:webhook,代码行数:12,代码来源:ProcessSerializer.php

示例12: run

 /**
  * @param $command
  * @param $projectPath
  * @param OutputInterface $output
  */
 protected function run($command, $projectPath, OutputInterface $output)
 {
     $process = new Process($command, $projectPath, array_merge($_SERVER, $_ENV), null, null);
     $process->run(function ($type, $line) use($output) {
         $output->write($line);
     });
 }
开发者ID:richdynamix,项目名称:magestead,代码行数:12,代码来源:ProcessCommand.php

示例13: runFix

 /**
  * @param string $path
  * @param Event  $event
  */
 protected static function runFix($path, Event $event)
 {
     $bin = self::getOption('phpcsfixer-bin', $event);
     $failOnError = self::getOption('phpcsfixer-fail-on-error', $event);
     $logPrepend = self::getOption('phpcsfixer-log-prepend', $event);
     $level = self::getOption('phpcsfixer-level', $event);
     $fixers = self::getOption('phpcsfixer-fixers', $event);
     $config = self::getOption('phpcsfixer-config', $event);
     $dryRun = self::getOption('phpcsfixer-dry-run', $event);
     $command = array($bin, 'fix', $path);
     if ($level) {
         $command[] = '--level=' . $level;
     }
     if (!empty($fixers) && is_array($fixers)) {
         $command[] = '--fixers=' . implode(',', $fixers);
     }
     if ($config) {
         $command[] = '--config=' . $config;
     }
     if ($dryRun === true) {
         $command[] = '--dry-run';
     }
     if (!$failOnError) {
         $command[] = '|| true';
     }
     $process = new Process(implode(' ', $command), null, null, null, null, []);
     $process->mustRun(function ($type, $buffer) use($event, $logPrepend) {
         self::writeProcessBuffer($type, $buffer, $event, $logPrepend);
     });
 }
开发者ID:javihgil,项目名称:composer-ci-tools,代码行数:34,代码来源:PhpCsFixer.php

示例14: execute

 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.");
 }
开发者ID:kohkimakimoto,项目名称:altax,代码行数:31,代码来源:SelfUpdateCommand.php

示例15: execute

 /**
  * @inheritDoc
  */
 protected function execute(InputInterface $input, OutputInterface $output, $retried = false)
 {
     if ($this->getContainer()->get('foreman.accessor')->ping()) {
         $output->writeln('<error>The Foreman Processor server is already running.');
         return;
     }
     if ($input->getOption('daemon')) {
         $phpPath = (new PhpExecutableFinder())->find();
         $process = new Process($phpPath . ' app/console foreman:processor:start' . ($input->getOption('verbose') ? ' -v' : ''));
         $process->setTimeout(0);
         $output->writeln('<info>Starting daemon server...');
         $process->start();
         $accessor = $this->getContainer()->get('foreman.accessor');
         $start = time();
         $interval = $this->getContainer()->getParameter('foreman.processor')['interval'];
         //When we try to ping the server the first time, it almost always fails.
         //The server isn't started yet by the time we get here, so we wait.
         //Timeout = 3 seconds. Should be enough for all servers.
         while (!$accessor->ping() && time() - $start < 3) {
             sleep($interval);
         }
         if ($accessor->ping()) {
             $status = $accessor->status();
             $output->writeln('<info>The server was started successfully with PID ' . $status['pid'] . '</info>');
         } else {
             $output->writeln('<error>The server could not be started at this moment.</error>');
             $output->writeln('Please check if the server port (' . $this->getContainer()->getParameter('foreman.processor.port') . ') is available.');
             $output->writeln('If you have closed the server recently, the connection may not have released. Try again ' . 'in a few seconds.');
         }
     } else {
         $output->writeln('<info>Starting the Foreman Processor...</info>');
         $this->getContainer()->get('foreman.processor')->start($output, $input->getOption('verbose'));
     }
 }
开发者ID:naroga,项目名称:foreman,代码行数:37,代码来源:StartCommand.php


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