本文整理汇总了PHP中Symfony\Component\Console\Input\ArgvInput::getArgument方法的典型用法代码示例。如果您正苦于以下问题:PHP ArgvInput::getArgument方法的具体用法?PHP ArgvInput::getArgument怎么用?PHP ArgvInput::getArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Input\ArgvInput
的用法示例。
在下文中一共展示了ArgvInput::getArgument方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* @inheritdoc
*/
public static function run($request, $response, $args)
{
global $argv;
$container = static::getApp()->getContainer();
$pathResolver = $container['pathResolver'];
$filesystem = new Filesystem();
$creator = new MigrationCreator($filesystem);
$definition = new InputDefinition();
$definition->addArgument(new InputArgument('name', InputArgument::REQUIRED));
$definition->addOption(new InputOption('table', 't', InputOption::VALUE_OPTIONAL));
$input = new ArgvInput(array_slice($argv, 1), $definition);
$output = new ConsoleOutput();
$path = $pathResolver->getAlias('@db/migrations');
$name = $input->getArgument('name');
$table = $input->getOption('table');
$file = pathinfo($creator->create($name, $path, $table), PATHINFO_FILENAME);
\dump($file);
}
示例2: bin
/**
* `psysh` command line executable.
*
* @return Closure
*/
function bin()
{
return function () {
$usageException = null;
$input = new ArgvInput();
try {
$input->bind(new InputDefinition(array(new InputOption('help', 'h', InputOption::VALUE_NONE), new InputOption('config', 'c', InputOption::VALUE_REQUIRED), new InputOption('version', 'v', InputOption::VALUE_NONE), new InputOption('cwd', null, InputOption::VALUE_REQUIRED), new InputArgument('include', InputArgument::IS_ARRAY))));
} catch (\RuntimeException $e) {
$usageException = $e;
}
$config = array();
// Handle --config
if ($configFile = $input->getOption('config')) {
$config['configFile'] = $configFile;
}
$shell = new Shell(new Configuration($config));
// Handle --help
if ($usageException !== null || $input->getOption('help')) {
if ($usageException !== null) {
echo $usageException->getMessage() . PHP_EOL . PHP_EOL;
}
$version = $shell->getVersion();
$name = basename(reset($_SERVER['argv']));
echo <<<EOL
{$version}
Usage:
{$name} [--version] [--help] [files...]
Options:
--help -h Display this help message.
--config -c Use an alternate PsySH config file location.
--cwd Use an alternate working directory.
--version -v Display the PsySH version.
EOL;
exit($usageException === null ? 0 : 1);
}
// Handle --version
if ($input->getOption('version')) {
echo $shell->getVersion() . PHP_EOL;
exit(0);
}
// Pass additional arguments to Shell as 'includes'
$shell->setIncludes($input->getArgument('include'));
try {
// And go!
$shell->run();
} catch (Exception $e) {
echo $e->getMessage() . PHP_EOL;
// TODO: this triggers the "exited unexpectedly" logic in the
// ForkingLoop, so we can't exit(1) after starting the shell...
// fix this :)
// exit(1);
}
};
}
示例3: InputDefinition
use Elastica\Client;
use Elastica\Document;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
$inputDefinition = new InputDefinition();
$inputDefinition->addArgument(new InputArgument('host', InputArgument::REQUIRED));
$inputDefinition->addArgument(new InputArgument('tree', InputArgument::REQUIRED));
$options = [['port', null, InputOption::VALUE_REQUIRED, '', 9200], ['index', null, InputOption::VALUE_REQUIRED, '', 'test'], ['type', null, InputOption::VALUE_REQUIRED, '', 'test'], ['treeLevels', null, InputOption::VALUE_REQUIRED, '', null], ['precision', null, InputOption::VALUE_REQUIRED, '', null], ['tab', null, InputOption::VALUE_NONE], ['bulk-size', null, InputOption::VALUE_REQUIRED, '', 10]];
foreach ($options as $option) {
$inputDefinition->addOption(new InputOption($option[0], $option[1], $option[2], $option[3], $option[4]));
}
$argvInput = new ArgvInput($argv, $inputDefinition);
$main = function () use($argvInput) {
$host = $argvInput->getArgument('host');
$port = $argvInput->getOption('port');
$indexName = $argvInput->getOption('index');
$typeName = $argvInput->getOption('type');
$treeLevels = $argvInput->getOption('treeLevels');
$precision = $argvInput->getOption('precision');
$tree = $argvInput->getArgument('tree');
$bulkSize = $argvInput->getOption('bulk-size');
$tab = $argvInput->getOption('tab');
if (!in_array($tree, ['quadtree', 'geohash'])) {
throw new \Exception(sprintf('Supported tree types are quadtree and geohash, "%s" given.', $tree));
}
if (!isset($treeLevels) && !isset($precision)) {
throw new \Exception('Test requires either treeLevels or precision to be set.');
}
if (isset($treeLevels) && isset($precision)) {
示例4: implode
<?php
require __DIR__ . '/vendor/autoload.php';
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
$inputDefinition = new InputDefinition();
$inputDefinition->addArgument(new InputArgument('host', InputArgument::REQUIRED));
$options = [['port', null, InputOption::VALUE_REQUIRED, '', 9200], ['index', null, InputOption::VALUE_REQUIRED, '', 'test'], ['type', null, InputOption::VALUE_REQUIRED, '', 'test']];
foreach ($options as $option) {
$inputDefinition->addOption(new InputOption($option[0], $option[1], $option[2], $option[3], $option[4]));
}
$precisions = [10, 50, 100, 250, 1000, 10000];
$trees = ['quadtree', 'geohash'];
$bulkSizes = [10, 50, 100, 250, 1000];
$argvInput = new ArgvInput($argv, $inputDefinition);
echo implode("\t", ['host', 'port', 'indexName', 'typeName', 'tree', 'treeLevels', 'precision', 'duration', 'totalFlushed', 'bulkSize', 'indexSize']) . PHP_EOL;
foreach ($trees as $tree) {
foreach ($precisions as $precision) {
foreach ($bulkSizes as $bulkSize) {
passthru(sprintf('php %s %s %s --port %s --index %s --type %s --precision %s --tab --bulk-size %s', __DIR__ . '/geo-indexing-test.php', $argvInput->getArgument('host'), $tree, $argvInput->getOption('port'), $argvInput->getOption('index'), $argvInput->getOption('type'), $precision, $bulkSize));
}
}
}