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


PHP Process::run方法代码示例

本文整理汇总了PHP中Process::run方法的典型用法代码示例。如果您正苦于以下问题:PHP Process::run方法的具体用法?PHP Process::run怎么用?PHP Process::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Process的用法示例。


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

示例1: run

 /**
  * Runs the process.
  *
  * @param Closure|string|array $callback A PHP callback to run whenever there is some
  *                                       output available on STDOUT or STDERR
  *
  * @return integer The exit status code
  *
  * @api
  */
 public function run($callback = null)
 {
     if (null === $this->getCommandLine()) {
         $this->setCommandLine($this->getPhpBinary());
     }
     return parent::run($callback);
 }
开发者ID:nickaggarwal,项目名称:sample-symfony2,代码行数:17,代码来源:PhpProcess.php

示例2: fork

 public function fork(Process $children, $user_name = null, $group_name = null)
 {
     if ($this->allocateSHMPerChildren()) {
         $children->setSHMSegment(new SHMCache(uniqid('process_manager;shm_per_children' . $children->getInternalId()), $this->allocateSHMPerChildren));
     }
     pcntl_sigprocmask(SIG_BLOCK, array(SIGCHLD));
     $pid = pcntl_fork();
     // Error
     if ($pid == -1) {
         throw new RuntimeException('pcntl_fork() returned -1, are you sure you are running the script from CLI?');
     } else {
         if (!$pid) {
             if (!is_null($group_name)) {
                 if (!$this->setGroup($group_name)) {
                     throw new RuntimeException('set group_name failed. are you sure you have the privileges?');
                 }
             }
             if (!is_null($user_name)) {
                 if (!$this->setUser($user_name)) {
                     throw new RuntimeException('set user_name failed. are you sure you have the privileges?');
                 }
             }
             $children->run();
             exit;
             // redundant, added only for clarity
         } else {
             $children->setStarted(true);
             $this->children[] = $children;
             // Store the children's PID
             $children->setPid($pid);
             pcntl_sigprocmask(SIG_UNBLOCK, array(SIGCHLD));
         }
     }
 }
开发者ID:jiangtong1125,项目名称:Zebra-Multi-Process,代码行数:34,代码来源:ProcessManager.php

示例3: __invoke

 /**
  * Invoke filter
  * @param string $code
  * @param \WebLoader\Compiler $loader
  * @param string $file
  * @return string
  */
 public function __invoke($code, \WebLoader\Compiler $loader, $file)
 {
     if (pathinfo($file, PATHINFO_EXTENSION) === 'less') {
         $code = Process::run("{$this->bin} -", $code, dirname($file), $this->env);
     }
     return $code;
 }
开发者ID:ajaxovic,项目名称:WebLoader,代码行数:14,代码来源:LessBinFilter.php

示例4: run

 /**
  * Forks and run the process.
  *
  * @param Closure|string|array $callback A PHP callback to run whenever there is some
  *                                       output available on STDOUT or STDERR
  *
  * @return integer The exit status code
  */
 public function run($callback = null)
 {
     if (null === $this->commandline) {
         $this->commandline = $this->getPhpBinary();
     }
     parent::run($callback);
 }
开发者ID:skoop,项目名称:symfony-sandbox,代码行数:15,代码来源:PhpProcess.php

示例5: testRun

 /**
  * Tests Process::run
  */
 public function testRun()
 {
     $cmd = new Cmd('echo 1');
     $process = new Process();
     $process->addCommand($cmd);
     $res = $process->run();
     $this->assertEquals(0, $res->getCode(), 'echo should work everywhere');
 }
开发者ID:todiadiyatmo,项目名称:phpbu,代码行数:11,代码来源:ProcessTest.php

示例6: __invoke

 /**
  * Invoke filter
  *
  * @param string
  * @param \WebLoader\Compiler
  * @param string
  * @return string
  */
 public function __invoke($code, \WebLoader\Compiler $loader, $file = NULL)
 {
     if (pathinfo($file, PATHINFO_EXTENSION) === 'styl') {
         $cmd = $this->bin . ($this->compress ? ' -c' : '');
         $code = Process::run($cmd, $code);
     }
     return $code;
 }
开发者ID:BroukPytlik,项目名称:agility,代码行数:16,代码来源:StylusFilter.php

示例7: compileCoffee

 /**
  * @param string
  * @param bool|NULL
  * @return string
  */
 public function compileCoffee($source, $bare = NULL)
 {
     if (is_null($bare)) {
         $bare = $this->bare;
     }
     $cmd = $this->bin . ' -p -s' . ($bare ? ' -b' : '');
     return Process::run($cmd, $source);
 }
开发者ID:jfilla,项目名称:WebLoader,代码行数:13,代码来源:CoffeeScriptFilter.php

示例8: copy

 /**
  * Copies the specified hook to your repos git hooks directory only if it
  * doesn't already exist!
  * @param  string $hook the hook to copy/symlink
  * @return void
  */
 public function copy($hook)
 {
     if (false === file_exists(self::GIT_HOOKS_PATH . $hook)) {
         // exec('cp ' . __DIR__ . '/../../../../hooks/' . $hook . ' ' . GIT_HOOKS_PATH . $hook);
         $copy = new Process('cp ' . __DIR__ . '/../../../../hooks/' . $hook . ' .git/hooks/' . $hook);
         $copy->run();
     }
 }
开发者ID:GregoryCollett,项目名称:php-git-kit,代码行数:14,代码来源:HookCopier.php

示例9: detectProcessorNumberByGrep

 protected function detectProcessorNumberByGrep()
 {
     if (Utils::findBin('grep') && file_exists('/proc/cpuinfo')) {
         $process = new Process('grep -c ^processor /proc/cpuinfo 2>/dev/null');
         $process->run();
         $this->processorNumber = intval($process->getOutput());
         return $this->processorNumber;
     }
     return;
 }
开发者ID:phpbrew,项目名称:phpbrew,代码行数:10,代码来源:Machine.php

示例10: __invoke

 /**
  * Invoke filter
  *
  * @param  string $code
  * @param  \WebLoader\Compiler $compiler
  * @param  string $file
  * @return string
  */
 public function __invoke($code, \WebLoader\Compiler $compiler, $file = NULL)
 {
     if (pathinfo($file, PATHINFO_EXTENSION) === 'ts') {
         $out = substr_replace($file, 'js', -2);
         $cmd = sprintf("%s %s --target ES5 --out %s", $this->bin, escapeshellarg($file), escapeshellarg($out));
         Process::run($cmd, NULL, NULL, $this->env);
         $code = file_get_contents($out);
     }
     return $code;
 }
开发者ID:ajaxovic,项目名称:WebLoader,代码行数:18,代码来源:TypeScriptFilter.php

示例11: run

 public function run($callback = null)
 {
     if (null === $this->getCommandLine()) {
         if (false === ($php = $this->executableFinder->find())) {
             throw new \RuntimeException('Unable to find the PHP executable.');
         }
         $this->setCommandLine($php);
     }
     return parent::run($callback);
 }
开发者ID:phpsource,项目名称:pecl-caching-apc,代码行数:10,代码来源:PhpProcess.php

示例12: __invoke

 /**
  * Invoke filter
  *
  * @param string
  * @param \WebLoader\Compiler
  * @param string
  * @return string
  */
 public function __invoke($code, \WebLoader\Compiler $loader, $file = NULL)
 {
     if (pathinfo($file, PATHINFO_EXTENSION) === 'styl') {
         $path = $cmd = $this->bin . ($this->compress ? ' -c' : '') . ($this->includeCss ? ' --include-css' : '') . ' -I ' . pathinfo($file, PATHINFO_DIRNAME);
         try {
             $code = Process::run($cmd, $code);
         } catch (\RuntimeException $e) {
             throw new \WebLoader\WebLoaderException('Stylus Filter Error', 0, $e);
         }
     }
     return $code;
 }
开发者ID:jfilla,项目名称:WebLoader,代码行数:20,代码来源:StylusFilter.php

示例13: run

 /**
  * Execute la requete.
  */
 public function run()
 {
     // On envoie une deuxieme fois l'instance au gestionnaire d'erreurs
     // (1e fois = Webos->__construct())
     // Important pour ServerCallGroup !
     Error::setErrorsWebos($this);
     try {
         //On essaie d'executer l'action demandee
         $this->process->run();
     } catch (Exception $e) {
         //En cas d'erreur
         Error::catchException($e);
     }
     //On envoie la reponse HTTP
     $this->getHTTPResponse()->send();
 }
开发者ID:Tiger66639,项目名称:symbiose-raspberrypi,代码行数:19,代码来源:ServerCall.class.php

示例14: fork

 public function fork(Process $children)
 {
     if ($this->allocateSHMPerChildren()) {
         $children->setSHMSegment(new \Zebra\Ipcs\SHMCache(\uniqid('process_manager;shm_per_children' . $children->getInternalId()), $this->allocateSHMPerChildren));
     }
     \pcntl_sigprocmask(SIG_BLOCK, array(SIGCHLD));
     $pid = \pcntl_fork();
     // Error
     if ($pid == -1) {
         throw new RuntimeException('pcntl_fork() returned -1, are you sure you are running the script from CLI?');
     } else {
         if (!$pid) {
             $children->run();
             exit;
             // redundant, added only for clarity
         } else {
             $children->setStarted(true);
             $this->children[] = $children;
             // Store the children's PID
             $children->setPid($pid);
             \pcntl_sigprocmask(SIG_UNBLOCK, array(SIGCHLD));
         }
     }
 }
开发者ID:gzweb,项目名称:Zebra-PHP-Framework,代码行数:24,代码来源:ProcessManager.class.php

示例15: executeCommand

 /**
  * Executes the given command via shell and returns the complete output as
  * a string
  *
  * @param string $command
  *
  * @return array(status, stdout, stderr)
  */
 protected function executeCommand($command)
 {
     if (class_exists('Symfony\\Component\\Process\\Process')) {
         $process = new \Symfony\Component\Process\Process($command, $this->env);
         if ($this->timeout !== false) {
             $process->setTimeout($this->timeout);
         }
     } else {
         $process = new Process($command, $this->env);
     }
     $process->run();
     return array($process->getExitCode(), $process->getOutput(), $process->getErrorOutput());
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:21,代码来源:AbstractGenerator.php


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