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


PHP ArgvInput::getOption方法代码示例

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


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

示例1: getConfig

 /**
  * Overrides the original method from phinx in order to return a tailored
  * Config object containing the connection details for the database.
  *
  * @return Phinx\Config\Config
  */
 public function getConfig()
 {
     if ($this->configuration) {
         return $this->configuration;
     }
     $dir = APP_DIR . DS . 'Resource' . DS . 'migrations';
     $migrationTable = 'phinxlog';
     if ($bundleName = $this->input->getOption('bundle')) {
         $dir = Bundles::getPath($bundleName) . DS . 'Resource' . DS . 'migrations';
     }
     return $this->configuration = new Config(['paths' => ['migrations' => $dir], 'environments' => ['default_migration_table' => $migrationTable, 'default_database' => getenv('RAD_ENVIRONMENT'), getenv('RAD_ENVIRONMENT') => \Rad\Configure\Config::get('migrations.environments.' . getenv('RAD_ENVIRONMENT'))]]);
 }
开发者ID:radphp,项目名称:migrations-bundle,代码行数:18,代码来源:ConfigurationTrait.php

示例2: onCommand

 public function onCommand(ConsoleCommandEvent $event)
 {
     $output = $event->getOutput();
     $input = new ArgvInput();
     try {
         $input->bind($this->getDefinition());
     } catch (\RuntimeException $e) {
     }
     $delay = filter_var($input->getOption('delay'), FILTER_VALIDATE_INT);
     if ($delay > 0) {
         $wakeupAt = time() + mt_rand(1, $delay);
         $output->writeln('<comment>Waiting until ' . date('Y-m-d H:i:s', $wakeupAt) . ' eRepublik time.</comment>');
         time_sleep_until($wakeupAt);
     }
     $this->configPath = $input->getOption('config');
     $this->loadConfig();
 }
开发者ID:erpk,项目名称:erbot,代码行数:17,代码来源:Application.php

示例3: isProfileOption

 /**
  * We need to add the profile enable option to all commands if we are in
  * the parameter mode.
  *
  * Inspired by
  * http://php-and-symfony.matthiasnoback.nl/2013/11/symfony2-add-a-global-option-to-console-commands-and-generate-pid-file/
  *
  * @param ConsoleCommandEvent $event
  * @return mixed
  */
 private function isProfileOption(ConsoleCommandEvent $event)
 {
     $inputDefinition = $event->getCommand()->getApplication()->getDefinition();
     $inputDefinition->addOption(new InputOption($this->optionName, null, InputOption::VALUE_NONE, '<info>JnsXhprofBundle</info>: Whether to profile this command with xhprof', null));
     // merge the application's input definition
     $event->getCommand()->mergeApplicationDefinition();
     $input = new ArgvInput();
     // we use the input definition of the command
     $input->bind($event->getCommand()->getDefinition());
     return $input->getOption($this->optionName);
 }
开发者ID:ChrisWesterfield,项目名称:MJR.ONE-CP,代码行数:21,代码来源:CommandListener.php

示例4: onConsoleCommand

 public function onConsoleCommand(ConsoleCommandEvent $event)
 {
     /**
      * Skip if command is not a daemon-command
      */
     if (!$event->getCommand() instanceof ContainerAwareDaemonCommand) {
         return true;
     }
     if (true !== $this->mergeDefinitions($event)) {
         throw new ExtendedConfigurationException('No definitions');
     }
     $input = new ArgvInput();
     $input->bind($event->getCommand()->getDefinition());
     if (true !== $this->addSignals()) {
         throw new \Exception('No signals!');
     }
     if (true === $input->getOption('log-memory')) {
         if (true !== $this->addWatchers()) {
             throw new \Exception('No watchers!');
         }
     }
     if (true === $input->getOption('daemonize') & function_exists('pcntl_fork')) {
         $processId = pcntl_fork();
         if ($processId === -1) {
             throw new \Exception('The process failed to fork.');
         } else {
             if ($processId) {
                 $this->logger->info($event->getCommand()->getName() . ' correctly started as a daemon');
                 exit(0);
             }
         }
         if (posix_setsid() == -1) {
             throw new \Exception("Unable to detach from the terminal window.");
         }
     } else {
         $event->getOutput()->writeln('<comment>Use --daemonize option to run the process in background.</comment>');
     }
     return true;
 }
开发者ID:skedone,项目名称:DaemonsBundle,代码行数:39,代码来源:DaemonizeEventListener.php

示例5: 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);
 }
开发者ID:canis-io,项目名称:slim-laravel-helpers,代码行数:21,代码来源:Migration_CreateAction.php

示例6: getContainer

 /**
  * @return \Symfony\Component\DependencyInjection\ContainerBuilder
  */
 protected function getContainer()
 {
     if ($this->container) {
         return $this->container;
     }
     // Load cli options:
     $input = new ArgvInput();
     $input->bind($this->getDefaultInputDefinition());
     $configPath = $input->getOption('config');
     // Make sure to set the full path when it is declared relative
     // This will fix some issues in windows.
     $filesystem = new Filesystem();
     if (!$filesystem->isAbsolutePath($configPath)) {
         $configPath = getcwd() . DIRECTORY_SEPARATOR . $configPath;
     }
     // Build the service container:
     $this->container = ContainerFactory::buildFromConfiguration($configPath);
     return $this->container;
 }
开发者ID:brzuchal,项目名称:grumphp,代码行数:22,代码来源:Application.php

示例7: getOption

 /**
  * @param string $name
  * @return mixed
  */
 public function getOption($name)
 {
     $this->options = $this->getOptions();
     return parent::getOption($name);
 }
开发者ID:nunodotferreira,项目名称:ApiGen,代码行数:9,代码来源:LiberalFormatArgvInput.php

示例8: 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);
            }
        };
    }
开发者ID:saj696,项目名称:pipe,代码行数:62,代码来源:functions.php

示例9: InputDefinition

<?php

use Symfony\Component\Console\Input\InputDefinition, Symfony\Component\Console\Input\InputArgument, Symfony\Component\Console\Input\InputOption, Symfony\Component\Console\Input\ArgvInput, Symfony\Component\Console\Output\ConsoleOutput;
require_once __DIR__ . '/../vendor/autoload.php';
$definition = new InputDefinition(array(new InputOption('reports', 'r', InputOption::VALUE_REQUIRED, 'Path of features files', './features'), new InputOption('features', 'f', InputOption::VALUE_REQUIRED, 'Path of reports', './reports'), new InputOption('server', 's', InputOption::VALUE_REQUIRED, 'Address to use', 'localhost:8001')));
$input = new ArgvInput(null, $definition);
$output = new ConsoleOutput();
$output->writeln('Bevahior Driven Development Wizard, by Jean-François Lépine <https://twitter.com/Halleck45>');
$features = $input->getOption('features');
$reports = $input->getOption('reports');
$server = $input->getOption('server');
$command = sprintf('GHERKIN_FEATURES=%4$s GHERKIN_REPORTS=%5$s %1$s -S %3$s  %2$s ', PHP_BINARY, $_SERVER['SCRIPT_FILENAME'], $server, $features, $reports);
$output->writeln(sprintf('<info>Listening on on http://%s</info>', $server));
shell_exec($command);
开发者ID:charlycoste,项目名称:BDDWizard,代码行数:14,代码来源:bdd-wizard.php

示例10: InputDefinition

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)) {
        throw new \Exception('Test requires either treeLevels or precision to be set, not both.');
开发者ID:bmichalski-poc,项目名称:php-elastic-geo-poc,代码行数:31,代码来源:geo-indexing-test.php

示例11: registerMigrateDB

 /**
  * @param InputInterface $input
  * @param DrupalStyle    $io
  */
 protected function registerMigrateDB(ArgvInput $input, DrupalStyle $io)
 {
     $dbType = $input->getOption('db-type');
     $dbHost = $input->getOption('db-host');
     $dbName = $input->getOption('db-name');
     $dbUser = $input->getOption('db-user');
     $dbPass = $input->getOption('db-pass');
     $dbPrefix = $input->getOption('db-prefix');
     $dbPort = $input->getOption('db-port');
     $this->addDBConnection($io, 'upgrade', 'default', $dbType, $dbName, $dbUser, $dbPass, $dbPrefix, $dbPort, $dbHost);
 }
开发者ID:ranqiangjun,项目名称:DrupalConsole,代码行数:15,代码来源:MigrationTrait.php

示例12: loadApiDocData

<?php

require __DIR__ . '/../vendor/autoload.php';
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\ArgvInput;
$defaultDataSrc = __DIR__ . '/../apidoc/api_data.json';
try {
    $inputDefinition = new InputDefinition(array(new InputOption('data-src', 's', InputOption::VALUE_OPTIONAL, 'Location of apidoc data.json file', $defaultDataSrc), new InputOption('data-target', 't', InputOption::VALUE_OPTIONAL, 'Where to write json output', null)));
    $input = new ArgvInput($argv, $inputDefinition);
    $dataSrc = $input->getOption('data-src');
    $dataTarget = $input->getOption('data-target');
    $targetStream = $dataTarget === null ? 'php://stdout' : 'file://' . $dataTarget;
    $targetHandle = fopen($targetStream, 'r+');
    if ($targetHandle === false) {
        throw new RuntimeException("Could not write to '{$targetStream}'");
    }
    $data = loadApiDocData($dataSrc);
    $version = findLatestVersion($data);
    $latestData = extractVersionData($data, $version);
    $groupedData = groupData($latestData);
    $outData = $groupedData;
    $outJson = json_encode($outData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
    fwrite($targetHandle, $outJson);
    fclose($targetHandle);
    echo PHP_EOL;
} catch (Exception $e) {
    echo $e;
    exit(1);
}
function loadApiDocData($file)
开发者ID:ChartBlocks,项目名称:data-server-docs,代码行数:31,代码来源:convertForDeveloperDocs.php

示例13: 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));
        }
    }
}
开发者ID:bmichalski-poc,项目名称:php-elastic-geo-poc,代码行数:25,代码来源:multi-geo-indexing-tests.php


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