本文整理汇总了PHP中Symfony\Component\Process\ExecutableFinder类的典型用法代码示例。如果您正苦于以下问题:PHP ExecutableFinder类的具体用法?PHP ExecutableFinder怎么用?PHP ExecutableFinder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ExecutableFinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCustomizedDrivers
public function testCustomizedDrivers()
{
$object = new DriversContainer();
$executableFinder = new ExecutableFinder();
$php = $executableFinder->find('php');
if (null === $php) {
$this->markTestSkipped('Unable to find mandatory PHP executable');
}
$object['configuration'] = array('ffmpeg.threads' => 42, 'ffmpeg.ffmpeg.timeout' => 42, 'ffmpeg.ffprobe.timeout' => 42, 'ffmpeg.ffmpeg.binaries' => $php, 'ffmpeg.ffprobe.binaries' => $php, 'imagine.driver' => 'gd', 'gs.timeout' => 42, 'gs.binaries' => $php, 'mp4box.timeout' => 42, 'mp4box.binaries' => $php, 'swftools.timeout' => 42, 'swftools.pdf2swf.binaries' => $php, 'swftools.swfrender.binaries' => $php, 'swftools.swfextract.binaries' => $php, 'unoconv.binaries' => $php, 'unoconv.timeout' => 42);
$this->assertEquals($php, $object['ffmpeg.ffmpeg']->getFFMpegDriver()->getProcessBuilderFactory()->getBinary());
$this->assertEquals($php, $object['ffmpeg.ffprobe']->getFFProbeDriver()->getProcessBuilderFactory()->getBinary());
$this->assertEquals($php, $object['ghostscript.transcoder']->getProcessBuilderFactory()->getBinary());
$this->assertInstanceOf('Imagine\\Gd\\Imagine', $object['imagine']);
$this->assertEquals($php, $object['swftools.driver-container']['pdf2swf']->getProcessBuilderFactory()->getBinary());
$this->assertEquals($php, $object['swftools.driver-container']['swfextract']->getProcessBuilderFactory()->getBinary());
$this->assertEquals($php, $object['swftools.driver-container']['swfrender']->getProcessBuilderFactory()->getBinary());
$this->assertEquals($php, $object['unoconv']->getProcessBuilderFactory()->getBinary());
$this->assertEquals($php, $object['mp4box']->getProcessBuilderFactory()->getBinary());
$this->assertEquals(42, $object['ffmpeg.ffmpeg']->getFFMpegDriver()->getConfiguration()->get('ffmpeg.threads'));
$this->assertEquals(42, $object['ffmpeg.ffmpeg']->getFFMpegDriver()->getProcessBuilderFactory()->getTimeout());
$this->assertEquals(42, $object['ffmpeg.ffprobe']->getFFProbeDriver()->getProcessBuilderFactory()->getTimeout());
$this->assertEquals(42, $object['ghostscript.transcoder']->getProcessBuilderFactory()->getTimeout());
$this->assertEquals(42, $object['swftools.driver-container']['pdf2swf']->getProcessBuilderFactory()->getTimeout());
$this->assertEquals(42, $object['swftools.driver-container']['swfextract']->getProcessBuilderFactory()->getTimeout());
$this->assertEquals(42, $object['swftools.driver-container']['swfrender']->getProcessBuilderFactory()->getTimeout());
$this->assertEquals(42, $object['unoconv']->getProcessBuilderFactory()->getTimeout());
$this->assertEquals(42, $object['mp4box']->getProcessBuilderFactory()->getTimeout());
}
示例2: render
function render($context = null, $vars = array())
{
$options = $this->options;
$compress = @$options["compress"] ?: false;
$outputFile = tempnam(sys_get_temp_dir(), 'metatemplate_template_less_output');
$finder = new ExecutableFinder();
$bin = @$this->options["less_bin"] ?: self::DEFAULT_LESSC;
$cmd = $finder->find($bin);
if ($cmd === null) {
throw new \UnexpectedValueException("'{$bin}' executable was not found. Make sure it's installed.");
}
if ($compress) {
$cmd .= ' -x';
}
if (array_key_exists('include_path', $this->options)) {
$cmd .= sprintf('--include-path %s', escapeshellarg(join(PATH_SEPARATOR, (array) $this->options['include_path'])));
}
$cmd .= " --no-color - {$outputFile}";
$process = new Process($cmd);
$process->setStdin($this->getData());
if ($this->isFile()) {
$process->setWorkingDirectory(dirname($this->source));
}
$process->setEnv(array('PATH' => getenv("PATH")));
$process->run();
$content = @file_get_contents($outputFile);
@unlink($outputFile);
if (!$process->isSuccessful()) {
throw new \RuntimeException("{$cmd} returned an error: " . $process->getErrorOutput());
}
return $content;
}
示例3: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$outputDir = $this->outputDirHandler->handleOutputDir($input, $output);
$guiBin = null;
if ($input->getOption('gui')) {
$finder = new ExecutableFinder();
$guiBin = $finder->find($input->getOption('gui-bin'));
if (null === $guiBin) {
throw new \InvalidArgumentException(sprintf('Could not locate GUI bin "%s"', $input->getOption('gui-bin')));
}
}
$generatedFiles = [];
$this->runnerHandler->runFromInput($input, $output, ['executor' => ['executor' => 'xdebug_profile', 'output_dir' => $outputDir, 'callback' => function ($iteration) use($outputDir, $guiBin, &$generatedFiles) {
$generatedFiles[] = $generatedFile = $outputDir . DIRECTORY_SEPARATOR . XDebugUtil::filenameFromIteration($iteration, '.cachegrind');
if ($guiBin) {
$process = new Process(sprintf($guiBin . ' ' . $generatedFile));
$process->run();
}
}], 'iterations' => [1]]);
$output->write(PHP_EOL);
$output->writeln(sprintf('<info>%s profile(s) generated:</info>', count($generatedFiles)));
$output->write(PHP_EOL);
foreach ($generatedFiles as $generatedFile) {
if (!file_exists($generatedFile)) {
throw new \InvalidArgumentException(sprintf('Profile "%s" was not generated. Maybe you do not have XDebug installed?', $generatedFile));
}
$output->writeln(sprintf(' %s', $generatedFile));
}
}
示例4: render
function render($context = null, $vars = array())
{
$finder = new ExecutableFinder();
$bin = @$this->options["tsc_bin"] ?: self::DEFAULT_TSC;
$cmd = $finder->find($bin);
if ($cmd === null) {
throw new \UnexpectedValueException("'{$bin}' executable was not found. Make sure it's installed.");
}
$inputFile = sys_get_temp_dir() . '/pipe_typescript_input_' . uniqid() . '.ts';
file_put_contents($inputFile, $this->getData());
$outputFile = tempnam(sys_get_temp_dir(), 'pipe_typescript_output_') . '.js';
$cmd .= " --out " . escapeshellarg($outputFile) . ' ' . escapeshellarg($inputFile);
$process = new Process($cmd);
$process->setEnv(array('PATH' => @$_SERVER['PATH'] ?: join(PATH_SEPARATOR, array("/bin", "/sbin", "/usr/bin", "/usr/local/bin", "/usr/local/share/npm/bin"))));
if ($this->isFile()) {
$process->setWorkingDirectory(dirname($this->source));
}
$process->run();
unlink($inputFile);
if ($process->getErrorOutput()) {
throw new \RuntimeException("tsc({$this->source}) returned an error:\n {$process->getErrorOutput()}");
}
$data = file_get_contents($outputFile);
unlink($outputFile);
return $data;
}
示例5: getConfigTreeBuilder
/**
* Generates the configuration tree builder.
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
*/
public function getConfigTreeBuilder()
{
$builder = new TreeBuilder();
$finder = new ExecutableFinder();
$builder->root('assetic')->children()->booleanNode('debug')->defaultValue($this->debug)->end()->booleanNode('use_controller')->defaultValue($this->debug)->end()->scalarNode('read_from')->defaultValue('%kernel.root_dir%/../web')->end()->scalarNode('write_to')->defaultValue('%assetic.read_from%')->end()->scalarNode('java')->defaultValue($finder->find('java', '/usr/bin/java'))->end()->scalarNode('node')->defaultValue($finder->find('node', '/usr/bin/node'))->end()->scalarNode('sass')->defaultValue($finder->find('sass', '/usr/bin/sass'))->end()->end()->fixXmlConfig('bundle')->children()->arrayNode('bundles')->defaultValue($this->bundles)->requiresAtLeastOneElement()->prototype('scalar')->validate()->ifNotInArray($this->bundles)->thenInvalid('%s is not a valid bundle.')->end()->end()->end()->end()->fixXmlConfig('asset')->children()->arrayNode('assets')->addDefaultsIfNotSet()->requiresAtLeastOneElement()->useAttributeAsKey('name')->prototype('array')->beforeNormalization()->ifTrue(function ($v) {
return !is_array($v);
})->then(function ($v) {
return array('inputs' => array($v));
})->end()->beforeNormalization()->always()->then(function ($v) {
// cast scalars as array
foreach (array('input', 'inputs', 'filter', 'filters') as $key) {
if (isset($v[$key]) && !is_array($v[$key])) {
$v[$key] = array($v[$key]);
}
}
// organize arbitrary options
foreach ($v as $key => $value) {
if (!in_array($key, array('input', 'inputs', 'filter', 'filters', 'option', 'options'))) {
$v['options'][$key] = $value;
unset($v[$key]);
}
}
return $v;
})->end()->fixXmlConfig('input')->fixXmlConfig('filter')->children()->arrayNode('inputs')->prototype('scalar')->end()->end()->arrayNode('filters')->prototype('scalar')->end()->end()->arrayNode('options')->useAttributeAsKey('name')->prototype('variable')->end()->end()->end()->end()->end()->end()->fixXmlConfig('filter')->children()->arrayNode('filters')->addDefaultsIfNotSet()->requiresAtLeastOneElement()->useAttributeAsKey('name')->prototype('variable')->treatNullLike(array())->validate()->ifTrue(function ($v) {
return !is_array($v);
})->thenInvalid('The assetic.filters config %s must be either null or an array.')->end()->end()->end()->end()->children()->arrayNode('twig')->addDefaultsIfNotSet()->defaultValue(array())->fixXmlConfig('function')->children()->arrayNode('functions')->addDefaultsIfNotSet()->defaultValue(array())->useAttributeAsKey('name')->prototype('variable')->treatNullLike(array())->validate()->ifTrue(function ($v) {
return !is_array($v);
})->thenInvalid('The assetic.twig.functions config %s must be either null or an array.')->end()->end()->end()->end()->end()->end();
return $builder;
}
示例6: setUpBeforeClass
public static function setUpBeforeClass()
{
$oldCwd = getcwd();
self::$gitRepo = sys_get_temp_dir() . '/composer-git-' . rand() . '/';
$locator = new ExecutableFinder();
if (!$locator->find('git')) {
self::$skipped = 'This test needs a git binary in the PATH to be able to run';
return;
}
if (!mkdir(self::$gitRepo) || !chdir(self::$gitRepo)) {
self::$skipped = 'Could not create and move into the temp git repo ' . self::$gitRepo;
return;
}
// init
$process = new ProcessExecutor();
$process->execute('git init', $null);
touch('foo');
$process->execute('git add foo', $null);
$process->execute('git commit -m init', $null);
// non-composed tag & branch
$process->execute('git tag 0.5.0', $null);
$process->execute('git branch oldbranch', $null);
// add composed tag & master branch
$composer = array('name' => 'a/b');
file_put_contents('composer.json', json_encode($composer));
$process->execute('git add composer.json', $null);
$process->execute('git commit -m addcomposer', $null);
$process->execute('git tag 0.6.0', $null);
// add feature-a branch
$process->execute('git checkout -b feature-a', $null);
file_put_contents('foo', 'bar feature');
$process->execute('git add foo', $null);
$process->execute('git commit -m change-a', $null);
// add version to composer.json
$process->execute('git checkout master', $null);
$composer['version'] = '1.0.0';
file_put_contents('composer.json', json_encode($composer));
$process->execute('git add composer.json', $null);
$process->execute('git commit -m addversion', $null);
// create tag with wrong version in it
$process->execute('git tag 0.9.0', $null);
// create tag with correct version in it
$process->execute('git tag 1.0.0', $null);
// add feature-b branch
$process->execute('git checkout -b feature-b', $null);
file_put_contents('foo', 'baz feature');
$process->execute('git add foo', $null);
$process->execute('git commit -m change-b', $null);
// add 1.0 branch
$process->execute('git checkout master', $null);
$process->execute('git branch 1.0', $null);
// add 1.0.x branch
$process->execute('git branch 1.1.x', $null);
// update master to 2.0
$composer['version'] = '2.0.0';
file_put_contents('composer.json', json_encode($composer));
$process->execute('git add composer.json', $null);
$process->execute('git commit -m bump-version', $null);
chdir($oldCwd);
}
示例7: testConfiguredUsage
public function testConfiguredUsage()
{
$executableFinder = new ExecutableFinder();
$php = $executableFinder->find('php');
if (null === $php) {
$this->markTestSkipped('Unable to find mandatory PHP executable');
}
$app = new Application();
$app->register(new MediaAlchemystServiceProvider(), array('media-alchemyst.configuration' => array('ffmpeg.threads' => 42, 'ffmpeg.ffmpeg.timeout' => 42, 'ffmpeg.ffprobe.timeout' => 42, 'ffmpeg.ffmpeg.binaries' => $php, 'ffmpeg.ffprobe.binaries' => $php, 'imagine.driver' => 'gd', 'gs.timeout' => 42, 'gs.binaries' => $php, 'mp4box.timeout' => 42, 'mp4box.binaries' => $php, 'swftools.timeout' => 42, 'swftools.pdf2swf.binaries' => $php, 'swftools.swfrender.binaries' => $php, 'swftools.swfextract.binaries' => $php, 'unoconv.binaries' => $php, 'unoconv.timeout' => 42)));
$drivers = $app['media-alchemyst']->getDrivers();
$this->assertEquals($php, $drivers['ffmpeg.ffmpeg']->getFFMpegDriver()->getProcessBuilderFactory()->getBinary());
$this->assertEquals($php, $drivers['ffmpeg.ffprobe']->getFFProbeDriver()->getProcessBuilderFactory()->getBinary());
$this->assertEquals($php, $drivers['ghostscript.transcoder']->getProcessBuilderFactory()->getBinary());
$this->assertInstanceOf('Imagine\\Gd\\Imagine', $drivers['imagine']);
$this->assertEquals($php, $drivers['swftools.driver-container']['pdf2swf']->getProcessBuilderFactory()->getBinary());
$this->assertEquals($php, $drivers['swftools.driver-container']['swfextract']->getProcessBuilderFactory()->getBinary());
$this->assertEquals($php, $drivers['swftools.driver-container']['swfrender']->getProcessBuilderFactory()->getBinary());
$this->assertEquals($php, $drivers['unoconv']->getProcessBuilderFactory()->getBinary());
$this->assertEquals($php, $drivers['mp4box']->getProcessBuilderFactory()->getBinary());
$this->assertEquals(42, $drivers['ffmpeg.ffmpeg']->getFFMpegDriver()->getConfiguration()->get('ffmpeg.threads'));
$this->assertEquals(42, $drivers['ffmpeg.ffmpeg']->getFFMpegDriver()->getProcessBuilderFactory()->getTimeout());
$this->assertEquals(42, $drivers['ffmpeg.ffprobe']->getFFProbeDriver()->getProcessBuilderFactory()->getTimeout());
$this->assertEquals(42, $drivers['ghostscript.transcoder']->getProcessBuilderFactory()->getTimeout());
$this->assertEquals(42, $drivers['swftools.driver-container']['pdf2swf']->getProcessBuilderFactory()->getTimeout());
$this->assertEquals(42, $drivers['swftools.driver-container']['swfextract']->getProcessBuilderFactory()->getTimeout());
$this->assertEquals(42, $drivers['swftools.driver-container']['swfrender']->getProcessBuilderFactory()->getTimeout());
$this->assertEquals(42, $drivers['unoconv']->getProcessBuilderFactory()->getTimeout());
$this->assertEquals(42, $drivers['mp4box']->getProcessBuilderFactory()->getTimeout());
}
示例8: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
$outputDir = $input->getOption('outdir');
$guiBin = null;
if ($input->getOption('gui')) {
$finder = new ExecutableFinder();
$guiBin = $finder->find($input->getOption('gui-bin'));
if (null === $guiBin) {
throw new \InvalidArgumentException(sprintf('Could not locate GUI bin "%s"', $input->getOption('gui-bin')));
}
}
if (!$this->filesystem->exists($outputDir)) {
$output->writeln(sprintf('<comment>// creating non-existing directory %s</comment>', $outputDir));
$this->filesystem->mkdir($outputDir);
}
$generatedFiles = array();
$this->runnerHandler->runFromInput($input, $output, array('executor' => array('executor' => 'xdebug', 'output_dir' => $outputDir, 'callback' => function ($iteration) use($outputDir, $guiBin, &$generatedFiles) {
$generatedFiles[] = $generatedFile = $outputDir . DIRECTORY_SEPARATOR . XDebugUtil::filenameFromIteration($iteration);
if ($guiBin) {
$process = new Process(sprintf($guiBin . ' ' . $generatedFile));
$process->run();
}
}), 'iterations' => 1));
$output->write(PHP_EOL);
$output->writeln(sprintf('<info>%s profile(s) generated:</info>', count($generatedFiles)));
$output->write(PHP_EOL);
foreach ($generatedFiles as $generatedFile) {
if (!file_exists($generatedFile)) {
throw new \InvalidArgumentException(sprintf('Profile "%s" was not generated. Maybe you do not have XDebug installed?', $generatedFile));
}
$this->output->writeln(sprintf(' %s', $generatedFile));
}
}
示例9: __construct
/**
* Creates a new runner.
*
* @param string|null $binDir The path to Composer's "bin-dir".
*/
public function __construct($binDir = null)
{
$phpFinder = new PhpExecutableFinder();
if (!($php = $phpFinder->find())) {
throw new RuntimeException('The "php" command could not be found.');
}
$puliFinder = new ExecutableFinder();
// Search:
// 1. in the current working directory
// 2. in Composer's "bin-dir"
// 3. in the system path
$searchPath = array_merge(array(getcwd()), (array) $binDir);
// Search "puli.phar" in the PATH and the current directory
if (!($puli = $puliFinder->find('puli.phar', null, $searchPath))) {
// Search "puli" in the PATH and Composer's "bin-dir"
if (!($puli = $puliFinder->find('puli', null, $searchPath))) {
throw new RuntimeException('The "puli"/"puli.phar" command could not be found.');
}
}
if (Path::hasExtension($puli, '.bat', true)) {
$this->puli = $puli;
} else {
$this->puli = $php . ' ' . $puli;
}
}
示例10: testLoadDefaultBin
public function testLoadDefaultBin()
{
$this->extension->load(array(), $this->container);
$finder = new ExecutableFinder();
$bowerLocation = $finder->find('bower', '/usr/bin/bower');
$this->assertParameter($bowerLocation, 'sp_bower.bower.bin');
}
示例11: findExecutable
public function findExecutable($name, $default = null, array $extraDirs = array())
{
$finder = new ExecutableFinder();
$extraDirs = array_merge($this->getDefaultDirs(), $extraDirs);
$executable = $finder->find($name, $default, $extraDirs);
return is_executable($executable) ? $executable : false;
}
示例12: setUp
public function setUp()
{
$finder = new ExecutableFinder();
$unoconv = $finder->find('unoconv');
if (null === $unoconv) {
$this->markTestSkipped('Unable to detect unoconv, mandatory for this test');
}
}
示例13: findExecutable
protected function findExecutable($name, $serverKey = null)
{
if ($serverKey && isset($_SERVER[$serverKey])) {
return $_SERVER[$serverKey];
}
$finder = new ExecutableFinder();
return $finder->find($name);
}
示例14: findExecutable
protected function findExecutable($name, $server = null)
{
if (!is_null($server) and getenv($server) !== false) {
return $_SERVER[$server];
}
$finder = new ExecutableFinder();
return $finder->find($name);
}
示例15: findExecutable
protected function findExecutable($name, $server = null)
{
if (!is_null($server) and isset($_SERVER[$server])) {
return $_SERVER[$server];
}
$finder = new ExecutableFinder();
return $finder->find($name);
}