當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Input\ArgvInput類代碼示例

本文整理匯總了PHP中Symfony\Component\Console\Input\ArgvInput的典型用法代碼示例。如果您正苦於以下問題:PHP ArgvInput類的具體用法?PHP ArgvInput怎麽用?PHP ArgvInput使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ArgvInput類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Constructor. This is run before any modules are loaded, so we can
  * initialise the console here.
  *
  * @param ContainerInterface $container The service container
  * @param array|null 		 $arguments Arguments to pass into the Console component
  *
  * @todo Change the environment earlier if possible. Can we make the context
  * run something before even Cog is bootstrapped?
  */
 public function __construct(ContainerInterface $container, array $arguments = null)
 {
     $this->_services = $container;
     $this->_services['console.commands'] = function () {
         return new CommandCollection(array(new Command\EventList(), new Command\ModuleList(), new Command\RouteList(), new Command\RouteCollectionTree(), new Command\Setup(), new Command\Status(), new Command\TaskGenerate(), new Command\TaskList(), new Command\TaskRun(), new Command\TaskRunScheduled(), new Command\AssetDump(), new Command\AssetGenerator(), new Command\MigrateInstall(), new Command\MigrateRollback(), new Command\MigrateReset(), new Command\MigrateRefresh(), new Command\MigrateRun(), new Command\DeployEvent(), new Command\DeployPermissions(), new Command\ModuleNamespace(), new Command\CacheClear()));
     };
     $this->_services['console.app'] = function ($c) {
         $app = new Application();
         $app->setContainer($c);
         $app->getDefinition()->addOption(new InputOption('--' . $app::ENV_OPT_NAME, '', InputOption::VALUE_OPTIONAL, 'The Environment name.'));
         // Add the commands
         foreach ($c['console.commands'] as $command) {
             $app->add($command);
         }
         return $app;
     };
     if (null === $arguments) {
         $arguments = $_SERVER['argv'];
     }
     $input = new ArgvInput($arguments);
     if ($env = $input->getParameterOption(array('--env'), '')) {
         $this->_services['environment']->setWithInstallation($env);
     }
     // Setup a fake request context
     $this->_services['http.request.context'] = function ($c) {
         $context = new \Message\Cog\Routing\RequestContext();
         return $context;
     };
 }
開發者ID:mothership-ec,項目名稱:cog,代碼行數:39,代碼來源:Console.php

示例2: loadCommands

 /**
  * @param OutputInterface $output
  */
 public function loadCommands(OutputInterface $output)
 {
     // $application is required to be defined in the register_command scripts
     $application = $this->application;
     require_once \OC::$SERVERROOT . '/core/register_command.php';
     if ($this->config->getSystemValue('installed', false)) {
         if (!\OCP\Util::needUpgrade()) {
             OC_App::loadApps();
             foreach (OC_App::getAllApps() as $app) {
                 $file = OC_App::getAppPath($app) . '/appinfo/register_command.php';
                 if (file_exists($file)) {
                     require $file;
                 }
             }
         } else {
             $output->writeln("ownCloud or one of the apps require upgrade - only a limited number of commands are available");
         }
     } else {
         $output->writeln("ownCloud is not installed - only a limited number of commands are available");
     }
     $input = new ArgvInput();
     if ($input->getFirstArgument() !== 'check') {
         $errors = \OC_Util::checkServer(\OC::$server->getConfig());
         if (!empty($errors)) {
             foreach ($errors as $error) {
                 $output->writeln($error['error']);
                 $output->writeln($error['hint']);
                 $output->writeln('');
             }
             throw new \Exception("Environment not properly prepared.");
         }
     }
 }
開發者ID:adolfo2103,項目名稱:hcloudfilem,代碼行數:36,代碼來源:application.php

示例3: testExecute_SpecificEntity_Association

 /**
  * @see FixturesExportCommand::execute
  */
 public function testExecute_SpecificEntity_Association()
 {
     $directoryPath = sys_get_temp_dir();
     $dumper = $this->getMockBuilder('\\Cosma\\Bundle\\TestingBundle\\Fixture\\Dumper')->disableOriginalConstructor()->setMethods(['dumpToYaml', 'setAssociation', 'setClassMetadataInfo'])->getMock();
     $dumper->expects($this->once())->method('dumpToYaml')->with($directoryPath)->will($this->returnValue($directoryPath . '/table.yml'));
     $dumper->expects($this->once())->method('setAssociation')->with(true)->will($this->returnValue(null));
     $classMetaDataInfo = $this->getMockBuilder('\\Doctrine\\ORM\\Mapping\\ClassMetadataInfo')->disableOriginalConstructor()->getMock();
     $dumper->expects($this->once())->method('setClassMetadataInfo')->with($classMetaDataInfo)->will($this->returnValue(null));
     $metaDataFactory = $this->getMockBuilder('\\Doctrine\\Common\\Persistence\\Mapping\\ClassMetadataFactory')->disableOriginalConstructor()->setMethods(['getMetadataFor'])->getMockForAbstractClass();
     $metaDataFactory->expects($this->once())->method('getMetadataFor')->with('BundleName:EntityName')->will($this->returnValue($classMetaDataInfo));
     $entityManager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->setMethods(['getMetadataFactory'])->getMock();
     $entityManager->expects($this->once())->method('getMetadataFactory')->will($this->returnValue($metaDataFactory));
     $doctrine = $this->getMockBuilder('\\Doctrine\\Bundle\\DoctrineBundle\\Registry')->disableOriginalConstructor()->setMethods(['getManager'])->getMock();
     $doctrine->expects($this->once())->method('getManager')->will($this->returnValue($entityManager));
     $container = new Container();
     $container->set('doctrine', $doctrine);
     $container->set('cosma_testing.fixture_dumper', $dumper);
     $command = $this->getMockBuilder('\\Cosma\\Bundle\\TestingBundle\\Command\\FixturesExportCommand')->disableOriginalConstructor()->setMethods(['getContainer'])->getMock();
     $command->expects($this->exactly(2))->method('getContainer')->will($this->returnValue($container));
     $reflectionClass = new \ReflectionClass($command);
     $dumperProperty = $reflectionClass->getParentClass()->getProperty('dumper');
     $dumperProperty->setAccessible(true);
     $dumperProperty->setValue($command, $dumper);
     $inputDefinition = new InputDefinition([new InputArgument('dumpDirectory', InputArgument::REQUIRED), new InputArgument('entity', InputArgument::OPTIONAL), new InputOption('associations', 'a', InputOption::VALUE_NONE)]);
     $input = new ArgvInput(['dummySoInputValidates' => 'dummy', 'dumpDirectory' => $directoryPath, 'entity' => 'BundleName:EntityName'], $inputDefinition);
     $input->setOption('associations', true);
     $output = new BufferedOutput();
     $reflectionClass = new \ReflectionClass($command);
     $executeMethod = $reflectionClass->getMethod('execute');
     $executeMethod->setAccessible(true);
     $executeMethod->invoke($command, $input, $output);
     $this->assertContains("successfully dumped in file  {$directoryPath}/table.yml", $output->fetch(), 'The entity was not dump successfully');
 }
開發者ID:stevepop,項目名稱:testing-bundle,代碼行數:36,代碼來源:FixturesExportCommandTest.php

示例4: initComposer

 public function initComposer(OutputInterface $output)
 {
     $input = new ArgvInput(['composer', 'init']);
     $input->setInteractive(true);
     /** @var InitCommand $command */
     $command = $this->getHelperSet()->getCommand()->getApplication()->find('init');
     return $this->execute($input, $output, $command);
 }
開發者ID:quickstrap,項目名稱:quickstrap,代碼行數:8,代碼來源:InitHelper.php

示例5: 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:EnmanuelCode,項目名稱:backend-laravel,代碼行數:62,代碼來源:functions.php

示例6: __construct

 public function __construct(ConsoleOutput $output, ArgvInput $input)
 {
     $this->output = $output;
     $env = $input->getParameterOption(['-e', '--env']);
     if (!$env) {
         $env = 'dev';
     }
     $this->kernel($env);
 }
開發者ID:umpirsky,項目名稱:pim-community-dev,代碼行數:9,代碼來源:migrate_product_template.php

示例7: isSafe

 public function isSafe(ArgvInput $input, $env)
 {
     if ('prod' == $env) {
         if (in_array($input->getFirstArgument(), $this->productionBlackList)) {
             return false;
         }
     }
     return true;
 }
開發者ID:hotfics,項目名稱:lichess-old,代碼行數:9,代碼來源:ConsoleGuardRail.php

示例8: 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

示例9: runLocateFile

 /**
  * Do the locateFile Action
  *
  * @param $arg
  * @param $dir
  * @return string
  */
 protected function runLocateFile($arg, $dir)
 {
     chdir($this->baseDir . '/' . $dir);
     $definition = new InputDefinition(array(new InputOption('configuration')));
     $input = new ArgvInput(array(), $definition);
     if ($arg) {
         $input->setOption('configuration', $arg);
     }
     $command = new VoidCommand('void');
     return $command->locateConfigFile($input);
 }
開發者ID:Slayug,項目名稱:castor,代碼行數:18,代碼來源:ConfigFileTest.php

示例10: __construct

 /**
  * @param ConsoleOutput $output
  * @param ArgvInput     $input
  */
 public function __construct(ConsoleOutput $output, ArgvInput $input)
 {
     $this->output = $output;
     $env = $input->getParameterOption(['-e', '--env']);
     if (!$env) {
         $env = 'dev';
     }
     $this->bootKernel($env);
     $schemaHelper = new SchemaHelper($this->container);
     $this->productTemplateTable = $schemaHelper->getTableOrCollection('product_template');
 }
開發者ID:juliensnz,項目名稱:pim-community-standard,代碼行數:15,代碼來源:migrate_product_template.php

示例11: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->write('loading all fixtures...........');
     $input = new ArgvInput();
     $input->setInteractive(false);
     $command = $this->getApplication()->find('doctrine:fixtures:load');
     $command->run($input, new NullOutput());
     $output->writeln('<info>OK</info>');
     $output->write('setting up match fixtures......');
     $this->getContainer()->get('oss.league.service.fixture')->createFixtures(1);
     $output->writeln('<info>OK</info>');
 }
開發者ID:kosak83,項目名稱:OpenSoccerStar,代碼行數:12,代碼來源:SetupCommand.php

示例12: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $definition = $this->getDefinition();
     $arguments = $definition->getArguments();
     $arguments['target']->setDefault($this->container->getParameter('kernel.root_dir') . '/../web/');
     $definition->setArguments($arguments);
     if (count($input->getArguments()) === 0) {
         $input = new ArgvInput(null, $definition);
         $input->setArgument('target', $this->container->getParameter('kernel.root_dir') . '/../web/');
     }
     return parent::execute($input, $output);
 }
開發者ID:alpixel,項目名稱:AlpixelCMSBundle,代碼行數:12,代碼來源:SitemapCommand.php

示例13: runCLI

 public static function runCLI($environment = 'dev', $debug = true)
 {
     set_time_limit(0);
     $input = new ArgvInput();
     $environment = $input->getParameterOption(array('--env', '-e'), $environment);
     $debug = !$input->hasParameterOption(array('--no-debug', '')) && $environment !== 'prod';
     if ($debug) {
         Debug::enable();
     }
     $kernel = new static($environment, $debug);
     $application = new Application($kernel);
     $application->run($input);
 }
開發者ID:morki,項目名稱:bounce-bundle,代碼行數:13,代碼來源:Kernel.php

示例14: console

 /**
  * Runs Symfony2 in console mode.
  *
  * @param string $kernelClass Class name for the kernel to be ran.
  */
 public static function console($kernelClass)
 {
     set_time_limit(0);
     $input = new ArgvInput();
     // decide env and debug info based on cli params
     $env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev');
     $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';
     if ($debug) {
         Debug::enable();
     }
     $kernel = new $kernelClass($env, $debug);
     $application = new Application($kernel);
     $application->run($input);
 }
開發者ID:michaldudek,項目名稱:flavour,代碼行數:19,代碼來源:Run.php

示例15: requirePackage

 public function requirePackage(OutputInterface $output, $package, $version = null, $dev = true)
 {
     $packageArg = sprintf("%s%s", $package, $version != null ? ':' . $version : null);
     $args = ['composer', 'require'];
     if ($dev) {
         $args[] = '--dev';
     }
     $args[] = $packageArg;
     $input = new ArgvInput($args);
     $input->setInteractive(true);
     /** @var RequireCommand $command */
     $command = $this->getHelperSet()->getCommand()->getApplication()->find('require');
     return $this->execute($input, $output, $command);
 }
開發者ID:quickstrap,項目名稱:quickstrap,代碼行數:14,代碼來源:RequireHelper.php


注:本文中的Symfony\Component\Console\Input\ArgvInput類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。