本文整理汇总了PHP中Symfony\Component\Process\PhpExecutableFinder::findArguments方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpExecutableFinder::findArguments方法的具体用法?PHP PhpExecutableFinder::findArguments怎么用?PHP PhpExecutableFinder::findArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Process\PhpExecutableFinder
的用法示例。
在下文中一共展示了PhpExecutableFinder::findArguments方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFindArguments
/**
* tests find() with the env var PHP_PATH
*/
public function testFindArguments()
{
$f = new PhpExecutableFinder();
if (defined('HHVM_VERSION')) {
$this->assertEquals($f->findArguments(), array('--php'), '::findArguments() returns HHVM arguments');
} else {
$this->assertEquals($f->findArguments(), array(), '::findArguments() returns no arguments');
}
}
示例2: getProcess
public function getProcess(Script $script, $dir)
{
if ($script->getResource() instanceof LocalResource) {
$bootstrap = $this->getLocalBootstrap($script->getResource());
} else {
$bootstrap = $this->getRemoteBootstrap($script->getResource());
}
$file = sprintf('%s/%s', $dir, self::BOOTSTRAP_FILENAME);
file_put_contents($file, $bootstrap);
$phpFinder = new PhpExecutableFinder();
$process = ProcessBuilder::create(array_merge(array($phpFinder->find(false)), $script->getConfiguration()->getPhpOptions(), $phpFinder->findArguments(), array($file), $script->getArguments()))->setEnv('PATH', $_SERVER['PATH'])->getProcess();
if (!defined('PHP_WINDOWS_VERSION_BUILD') && php_sapi_name() === 'cli') {
$process->setTty(true);
}
return $process;
}
示例3: guessComposerCommand
/**
* Guess and build the command to call composer.
*
* Search:
* - a executable composer (or composer.phar)
* - a file composer (or composer.phar) prefixed by php
*/
private function guessComposerCommand()
{
$candidateNames = array('composer', 'composer.phar');
$executableFinder = new ExecutableFinder();
foreach ($candidateNames as $candidateName) {
if ($composerPath = $executableFinder->find($candidateName, null, array(getcwd()))) {
return array(realpath($composerPath));
}
}
foreach ($candidateNames as $candidateName) {
$composerPath = sprintf('%s/%s', getcwd(), $candidateName);
if (file_exists($composerPath)) {
$phpFinder = new PhpExecutableFinder();
return array_merge(array($phpFinder->find(false), $composerPath), $phpFinder->findArguments());
}
}
return null;
}
示例4: iRunTheCommand
private function iRunTheCommand($command, $siteaccess = null)
{
$phpFinder = new PhpExecutableFinder();
if (!($phpPath = $phpFinder->find(false))) {
throw new \RuntimeException('The php executable could not be found, add it to your PATH environment variable and try again');
}
$arguments = $phpFinder->findArguments();
if (false !== ($ini = php_ini_loaded_file())) {
$arguments[] = '--php-ini=' . $ini;
}
$php = escapeshellarg($phpPath);
$phpArgs = implode(' ', array_map('escapeshellarg', $arguments));
$console = escapeshellarg('app/console');
$cmd = escapeshellarg($command);
$console .= ' --env=' . escapeshellarg('behat');
if ($siteaccess !== null) {
$console .= ' --siteaccess=' . escapeshellarg($siteaccess);
}
$commandLine = $php . ($phpArgs ? ' ' . $phpArgs : '') . ' ' . $console . ' ' . $cmd;
$process = new Process($commandLine);
$process->run();
if (!$process->isSuccessful()) {
throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command.', escapeshellarg($cmd)));
}
$this->scriptOutput = $process->getOutput();
}
示例5: executeCommand
/**
* Executes a Symfony command in separate process.
*
* Typically usefull when configuration has changed, our you are outside of Symfony context (Composer commands).
*
* Based on {@see \Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::executeCommand}.
*
* @param OutputInterface $output
* @param string $cmd eZ Platform command to execute, like 'ezplatform:solr_create_index'
* Escape any user provided arguments, like: 'assets:install '.escapeshellarg($webDir)
* @param int $timeout
*/
private function executeCommand(OutputInterface $output, $cmd, $timeout = 300)
{
$phpFinder = new PhpExecutableFinder();
if (!($phpPath = $phpFinder->find(false))) {
throw new \RuntimeException('The php executable could not be found, add it to your PATH environment variable and try again');
}
// We don't know which php arguments where used so we gather some to be on the safe side
$arguments = $phpFinder->findArguments();
if (false !== ($ini = php_ini_loaded_file())) {
$arguments[] = '--php-ini=' . $ini;
}
// Pass memory_limit in case this was specified as php argument, if not it will most likely be same as $ini.
if ($memoryLimit = ini_get('memory_limit')) {
$arguments[] = '-d memory_limit=' . $memoryLimit;
}
$phpArgs = implode(' ', array_map('escapeshellarg', $arguments));
$php = escapeshellarg($phpPath) . ($phpArgs ? ' ' . $phpArgs : '');
// Make sure to pass along relevant global Symfony options to console command
$console = escapeshellarg('app/console');
if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
$console .= ' -' . str_repeat('v', $output->getVerbosity() - 1);
}
if ($output->isDecorated()) {
$console .= ' --ansi';
}
$console .= ' --env=' . escapeshellarg($this->environment);
$process = new Process($php . ' ' . $console . ' ' . $cmd, null, null, null, $timeout);
$process->run(function ($type, $buffer) use($output) {
$output->write($buffer, false);
});
if (!$process->isSuccessful()) {
throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command.', escapeshellarg($cmd)));
}
}
示例6: getOrFindPhpExecutablePathAndArguments
/**
* @param string|null $phpExecutablePath
* @param array|null $phpArguments
*
* @return $this
*/
public function getOrFindPhpExecutablePathAndArguments(&$phpExecutablePath, &$phpArguments)
{
$phpExecutablePath = $this->phpExecutablePath;
$phpArguments = $this->phpArguments;
if ($phpExecutablePath === null || $phpArguments === null) {
$executableFinder = new PhpExecutableFinder();
if ($phpExecutablePath === null) {
$phpExecutablePath = $executableFinder->find(false);
if ($phpExecutablePath === false) {
throw new Exception\RuntimeException('Unable to find the PHP executable.');
}
}
if ($phpArguments === null) {
$phpArguments = $executableFinder->findArguments();
}
}
return $this;
}