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


PHP Console\Application類代碼示例

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


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

示例1: setConsole

 /**
  * Config doctrine console
  *
  * @param Application $console
  * @param EntityManager $entityManager
  * @return Application
  */
 static function setConsole(Application $console, EntityManager $entityManager)
 {
     $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array('db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($entityManager->getConnection()), 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($entityManager)));
     $console->setHelperSet($helperSet);
     $console->addCommands(array(new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(), new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(), new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(), new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(), new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(), new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(), new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand()));
     return $console;
 }
開發者ID:RamEduard,項目名稱:rameduard.github.io,代碼行數:14,代碼來源:ConfigConsole.php

示例2: create

 /**
  * @return Application
  */
 public function create()
 {
     $app = new Application(Message::NAME, Message::VERSION);
     $app->setDefaultCommand(Message::COMMAND);
     $app->add($this->createAnalyzeCommand());
     return $app;
 }
開發者ID:EvKoh,項目名稱:PhpDependencyAnalysis,代碼行數:10,代碼來源:ApplicationFactory.php

示例3: shouldExecuteConsumeCommand

 /**
  * @test
  */
 public function shouldExecuteConsumeCommand()
 {
     $application = new Application('prod');
     // Add command
     $command = new TestableConsumerCommand('fake:consumer', $this->getMockForAbstractClass('Boot\\RabbitMQ\\Consumer\\AbstractConsumer', [$this->queueTemplate], 'MockConsumer'), $this->createLogger());
     $application->add($command);
     // Create command tester
     $commandTester = new CommandTester($command);
     // Execute consumer
     $commandTester->execute(['command' => $command->getName()]);
     // Should have declared the queue once
     $this->assertEquals(1, $this->basicQueueDeclareInvocations->getInvocationCount());
     $args = $this->basicQueueDeclareInvocations->getInvocations()[0]->parameters;
     // Make sure that the queue name is correct
     $this->assertEquals('some_test_queue', $args[0]);
     // Make sure that the queue is durable
     $this->assertTrue($args[2], 'The queue is not durable!');
     // Make sure that the queue is not automatically deleted
     $this->assertFalse($args[4], 'The queue is automatically deleted!');
     // Should have declared the quality of service once
     $this->assertEquals(1, $this->basicQosInvocations->getInvocationCount());
     // Should have declared the quality of service once
     $this->assertEquals(1, $this->basicConsumeInvocations->getInvocationCount());
     // The wait method should have been invoked once
     $this->assertEquals(1, $this->waitInvocations->getInvocationCount());
     // Should have status code 0
     $this->assertEquals(0, $commandTester->getStatusCode());
 }
開發者ID:leadtech,項目名稱:boot-rabbit-mq,代碼行數:31,代碼來源:FaultTolerantBehaviourConsumerTest.php

示例4: getApplicationDocument

 /**
  * @param Application $application
  * @param string|null $namespace
  *
  * @return \DOMDocument
  */
 public function getApplicationDocument(Application $application, $namespace = null)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->appendChild($rootXml = $dom->createElement('symfony'));
     if ($application->getName() !== 'UNKNOWN') {
         $rootXml->setAttribute('name', $application->getName());
         if ($application->getVersion() !== 'UNKNOWN') {
             $rootXml->setAttribute('version', $application->getVersion());
         }
     }
     $rootXml->appendChild($commandsXML = $dom->createElement('commands'));
     $description = new ApplicationDescription($application, $namespace);
     if ($namespace) {
         $commandsXML->setAttribute('namespace', $namespace);
     }
     foreach ($description->getCommands() as $command) {
         $this->appendDocument($commandsXML, $this->getCommandDocument($command));
     }
     if (!$namespace) {
         $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces'));
         foreach ($description->getNamespaces() as $namespaceDescription) {
             $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
             $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']);
             foreach ($namespaceDescription['commands'] as $name) {
                 $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
                 $commandXML->appendChild($dom->createTextNode($name));
             }
         }
     }
     return $dom;
 }
開發者ID:Ener-Getick,項目名稱:symfony,代碼行數:37,代碼來源:XmlDescriptor.php

示例5: setUp

 public function setUp()
 {
     $application = new Application();
     $application->add(new UserTokenGenerateCommand());
     $this->command = $application->find('user:token:generate');
     $this->commandTester = new CommandTester($this->command);
 }
開發者ID:jlekowski,項目名稱:battleships-api,代碼行數:7,代碼來源:UserTokenGenerateCommandTest.php

示例6: setUp

 protected function setUp()
 {
     $application = new Application();
     $application->add(new RepositoryTransferCommand($this->container));
     $command = $application->get(RepositoryTransferCommand::COMMAND_NAME);
     $this->commandTester = new CommandTester($command);
 }
開發者ID:nick-jones,項目名稱:php-ucd,代碼行數:7,代碼來源:RepositoryTransferCommandTest.php

示例7: createApplication

 public function createApplication($className)
 {
     $app = new Application('Robo', self::VERSION);
     $roboTasks = new $className();
     $commandNames = array_filter(get_class_methods($className), function ($m) {
         return !in_array($m, ['__construct']);
     });
     $passThrough = $this->passThroughArgs;
     foreach ($commandNames as $commandName) {
         $command = $this->createCommand(new TaskInfo($className, $commandName));
         $command->setCode(function (InputInterface $input) use($roboTasks, $commandName, $passThrough) {
             // get passthru args
             $args = $input->getArguments();
             array_shift($args);
             if ($passThrough) {
                 $args[key(array_slice($args, -1, 1, TRUE))] = $passThrough;
             }
             $args[] = $input->getOptions();
             $res = call_user_func_array([$roboTasks, $commandName], $args);
             if (is_int($res)) {
                 exit($res);
             }
             if (is_bool($res)) {
                 exit($res ? 0 : 1);
             }
             if ($res instanceof Result) {
                 exit($res->getExitCode());
             }
         });
         $app->add($command);
     }
     return $app;
 }
開發者ID:roland-d,項目名稱:Robo,代碼行數:33,代碼來源:Runner.php

示例8: setUp

 /**
  * Setup tests
  * @return void
  */
 protected function setUp()
 {
     $application = new Application();
     $application->add(new SearchCommand());
     $this->command = $application->find('search');
     $this->commandTester = new CommandTester($this->command);
 }
開發者ID:cedric59,項目名稱:infogreffe-unofficial-api,代碼行數:11,代碼來源:SearchCommandTest.php

示例9: testShouldReturnErrorIfThereIsFilesWithWrongStyle

 public function testShouldReturnErrorIfThereIsFilesWithWrongStyle()
 {
     $kernel = $this->getMock(\stdClass::class);
     /* @var \Behat\Gherkin\Parser|\PHPUnit_Framework_MockObject_MockObject $parser */
     $parser = $this->getMockBuilder(Parser::class)->disableOriginalConstructor()->getMock();
     /* @var \Behat\Gherkin\Node\FeatureNode|\PHPUnit_Framework_MockObject_MockObject $feature */
     $feature = $this->getMockBuilder(FeatureNode::class)->disableOriginalConstructor()->getMock();
     $feature->expects(self::once())->method('hasTags')->willReturn(true);
     $feature->expects(self::once())->method('getKeyword')->willReturn('Feature');
     $feature->expects(self::once())->method('getTags')->willReturn(['users', 'another-feature', 'another-tag']);
     $feature->expects(self::once())->method('getTitle')->willReturn('User registration');
     $feature->expects(self::once())->method('hasDescription')->willReturn(true);
     $feature->expects(self::once())->method('getDescription')->willReturn("In order to order products\n" . "As a visitor\n" . "I need to be able to create an account in the store");
     $feature->expects(self::once())->method('hasBackground')->willReturn(true);
     $feature->expects(self::once())->method('getBackground')->willReturn($this->getBackground());
     $feature->expects(self::once())->method('hasScenarios')->willReturn(false);
     $parser->expects(self::once())->method('parse')->willReturn($feature);
     $application = new Application($kernel);
     $application->add(new CheckGherkinCodeStyle(null, $parser));
     $command = $application->find('gherkin:check');
     $commandTester = new CommandTester($command);
     $commandTester->execute(['directory' => __DIR__ . '/../assets/left-aligned.feature']);
     self::assertRegExp('/Wrong style/', $commandTester->getDisplay());
     self::assertNotRegExp('/I need to be able to create an account in the store/', $commandTester->getDisplay());
 }
開發者ID:malukenho,項目名稱:kawaii-gherkin,代碼行數:25,代碼來源:CheckGherkinCodeStyleTest.php

示例10: setApplicationDocumentManager

 public static function setApplicationDocumentManager(Application $application, $dmName)
 {
     $service = null === $dmName ? 'doctrine_phpcr.odm.document_manager' : 'doctrine_phpcr.odm.' . $dmName . '_document_manager';
     $documentManager = $application->getKernel()->getContainer()->get($service);
     $helperSet = $application->getHelperSet();
     $helperSet->set(new DocumentManagerHelper(null, $documentManager));
 }
開發者ID:rejsmont,項目名稱:DoctrinePHPCRBundle,代碼行數:7,代碼來源:DoctrineCommandHelper.php

示例11: testCommand

 public function testCommand()
 {
     $app = new Application('Propel', Propel::VERSION);
     $command = new DatabaseReverseCommand();
     $app->add($command);
     $currentDir = getcwd();
     $outputDir = __DIR__ . '/../../../../reversecommand';
     chdir(__DIR__ . '/../../../../Fixtures/bookstore');
     $input = new \Symfony\Component\Console\Input\ArrayInput(array('command' => 'database:reverse', '--database-name' => 'reverse-test', '--output-dir' => $outputDir, '--verbose' => true, '--platform' => ucfirst($this->getDriver()) . 'Platform', 'connection' => $this->getConnectionDsn('bookstore-schemas', true)));
     $output = new \Symfony\Component\Console\Output\StreamOutput(fopen("php://temp", 'r+'));
     $app->setAutoExit(false);
     $result = $app->run($input, $output);
     chdir($currentDir);
     if (0 !== $result) {
         rewind($output->getStream());
         echo stream_get_contents($output->getStream());
     }
     $this->assertEquals(0, $result, 'database:reverse tests exited successfully');
     $databaseXml = simplexml_load_file($outputDir . '/schema.xml');
     $this->assertEquals('reverse-test', $databaseXml['name']);
     $this->assertGreaterThan(20, $databaseXml->xpath("table"));
     $table = $databaseXml->xpath("table[@name='acct_access_role']");
     $this->assertCount(1, $table);
     $table = $table[0];
     $this->assertEquals('acct_access_role', $table['name']);
     $this->assertEquals('AcctAccessRole', $table['phpName']);
     $this->assertCount(2, $table->xpath('column'));
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:28,代碼來源:DatabaseReverseTest.php

示例12: setup

 public function setup()
 {
     $app = new Application();
     $app->add(new UpdateCommand());
     $this->cmd = $app->find('update');
     $this->tester = new CommandTester($this->cmd);
 }
開發者ID:jwpage,項目名稱:composerdoc,代碼行數:7,代碼來源:UpdateCommandTest.php

示例13: boot

 /**
  * Bootstraps the application.
  *
  * This method is called after all services are registered
  * and should be used for "dynamic" configuration (whenever
  * a service must be requested).
  *
  * @param Application $app
  */
 public function boot(Application $app)
 {
     $helperSet = new HelperSet(array('connection' => new ConnectionHelper($app['db']), 'dialog' => new DialogHelper()));
     if (isset($app['orm.em'])) {
         $helperSet->set(new EntityManagerHelper($app['orm.em']), 'em');
     }
     $this->console->setHelperSet($helperSet);
     $commands = array('Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\ExecuteCommand', 'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\GenerateCommand', 'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\MigrateCommand', 'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\StatusCommand', 'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\VersionCommand');
     // @codeCoverageIgnoreStart
     if (true === $this->console->getHelperSet()->has('em')) {
         $commands[] = 'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\DiffCommand';
     }
     // @codeCoverageIgnoreEnd
     $configuration = new Configuration($app['db'], $app['migrations.output_writer']);
     $configuration->setMigrationsDirectory($app['migrations.directory']);
     $configuration->setName($app['migrations.name']);
     $configuration->setMigrationsNamespace($app['migrations.namespace']);
     $configuration->setMigrationsTableName($app['migrations.table_name']);
     $configuration->registerMigrationsFromDirectory($app['migrations.directory']);
     foreach ($commands as $name) {
         /** @var AbstractCommand $command */
         $command = new $name();
         $command->setMigrationConfiguration($configuration);
         $this->console->add($command);
     }
 }
開發者ID:Leemo,項目名稱:silex-doctrine-migrations-provider,代碼行數:35,代碼來源:DoctrineMigrationsProvider.php

示例14: testExecute

 public function testExecute()
 {
     $session = $this->buildSession();
     $application = new Application();
     $application->add($this->newTestedInstance()->setSession($session));
     $command = $application->find('pomm:generate:model');
     $command_args = ['command' => $command->getName(), 'config-name' => 'pomm_test', 'schema' => 'pomm_test', 'relation' => 'beta', '--prefix-ns' => 'Model', '--prefix-dir' => 'tmp'];
     $tester = new CommandTester($command);
     $options = ['decorated' => false];
     $tester->execute($command_args, $options);
     $this->string($tester->getDisplay())->isEqualTo(" ✓  Creating file 'tmp/Model/PommTest/PommTestSchema/BetaModel.php'." . PHP_EOL)->string(file_get_contents('tmp/Model/PommTest/PommTestSchema/BetaModel.php'))->isEqualTo(file_get_contents('sources/tests/Fixture/BetaModel.php'))->exception(function () use($tester, $command, $command_args) {
         $tester->execute($command_args);
     })->isInstanceOf('\\PommProject\\ModelManager\\Exception\\GeneratorException')->message->contains('--force');
     $tester->execute(array_merge($command_args, ['--force' => null]), $options);
     $this->string($tester->getDisplay())->isEqualTo(" ✓  Overwriting file 'tmp/Model/PommTest/PommTestSchema/BetaModel.php'." . PHP_EOL)->string(file_get_contents('tmp/Model/PommTest/PommTestSchema/BetaModel.php'))->isEqualTo(file_get_contents('sources/tests/Fixture/BetaModel.php'));
     $tester->execute(array_merge($command_args, ['relation' => 'dingo']), $options);
     $this->string($tester->getDisplay())->isEqualTo(" ✓  Creating file 'tmp/Model/PommTest/PommTestSchema/DingoModel.php'." . PHP_EOL)->string(file_get_contents('tmp/Model/PommTest/PommTestSchema/DingoModel.php'))->isEqualTo(file_get_contents('sources/tests/Fixture/DingoModel.php'));
     $inspector = new Inspector();
     $inspector->initialize($session);
     if (version_compare($inspector->getVersion(), '9.3', '>=') === true) {
         $tester->execute(array_merge($command_args, ['relation' => 'pluto']), $options);
         $this->string($tester->getDisplay())->isEqualTo(" ✓  Creating file 'tmp/Model/PommTest/PommTestSchema/PlutoModel.php'." . PHP_EOL)->string(file_get_contents('tmp/Model/PommTest/PommTestSchema/PlutoModel.php'))->isEqualTo(file_get_contents('sources/tests/Fixture/PlutoModel.php'));
     }
     $command_args['--prefix-dir'] = "tmp/Model";
     $tester->execute(array_merge($command_args, ['--psr4' => null, '--force' => null]), $options);
     $this->string($tester->getDisplay())->isEqualTo(" ✓  Overwriting file 'tmp/Model/PommTest/PommTestSchema/BetaModel.php'." . PHP_EOL)->string(file_get_contents('tmp/Model/PommTest/PommTestSchema/BetaModel.php'))->isEqualTo(file_get_contents('sources/tests/Fixture/BetaModel.php'));
 }
開發者ID:pomm-project,項目名稱:cli,代碼行數:27,代碼來源:GenerateRelationModel.php

示例15: setUp

 public function setUp()
 {
     $application = new Application();
     $application->add(new CreateTenantCommand());
     $this->command = $application->get('swp:tenant:create');
     $this->question = $this->command->getHelper('question');
 }
開發者ID:SuperdeskWebPublisher,項目名稱:SWPMultiTenancyBundle,代碼行數:7,代碼來源:CreateTenantCommandTest.php


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