本文整理匯總了PHP中Symfony\Component\Console\Output\OutputInterface::isDebug方法的典型用法代碼示例。如果您正苦於以下問題:PHP OutputInterface::isDebug方法的具體用法?PHP OutputInterface::isDebug怎麽用?PHP OutputInterface::isDebug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Output\OutputInterface
的用法示例。
在下文中一共展示了OutputInterface::isDebug方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testEnv
private function testEnv(array $functions, $url, OutputInterface $output)
{
$soapClient = new \SoapClient($url, array('cache_wsdl' => 0, 'trace' => 1, 'soap_version' => SOAP_1_1));
foreach ($functions as $function => $parameters) {
$output->writeln('Test de la fonction soap <comment>' . $function . '</comment>');
$output->writeln('Parameters : ');
dump($parameters);
if (!array_key_exists('methodCall', $this->config) || $this->config['methodCall'] == 'soapCall') {
$result = $soapClient->__soapCall($function, $parameters);
} else {
$result = $soapClient->{$function}($parameters);
}
$headers = $soapClient->__getLastResponseHeaders();
if ($output->isDebug()) {
$output->writeln('Entete de la reponse : ');
dump($headers);
}
if (false === ($site = $this->getSiteHeader($headers))) {
throw new \Exception('Site Header introuvable dans la réponse.', 1);
}
$output->writeln('Serveur ayant repondu : <info>' . $site . '</info>');
$output->writeln('Reponse : ');
dump($result);
if ($output->isDebug()) {
dump($soapClient->__getLastResponse());
}
}
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
Wp::load();
$targetTheme = null;
$targetThemeSlug = $input->getArgument('theme');
if (static::CURRENT_THEME == $input->getArgument('theme')) {
// no user chosen theme: load current
/** @var \WP_Theme $targetTheme */
$targetTheme = wp_get_theme();
$targetThemeSlug = $targetTheme->get_stylesheet();
}
if (!$targetTheme) {
// load user chosen theme
$targetTheme = wp_get_theme($targetThemeSlug);
}
if (!$targetTheme->exists()) {
throw new \DomainException('Theme ' . $targetThemeSlug . ' does not exist.');
}
if ($output->isDebug()) {
$output->writeln('Theme: ' . $targetTheme->get_stylesheet());
}
$morphMethod = $this->getMorphMethod($input);
// resolve readable name
$name = $targetThemeSlug;
if ($targetTheme->get('Name')) {
$name = $targetTheme->get('Name');
}
$this->verbose('Checking ' . $name);
// resolve theme text domain
$textDomain = $name;
if ($targetTheme->get('TextDomain')) {
$textDomain = $targetTheme->get('TextDomain');
}
$this->verbose(' (TextDomain: ' . $textDomain . ')' . PHP_EOL);
$langPath = WpTheme::resolveLanguagesPath($targetTheme);
// fetch strings
$extractor = new WordPressExtractor();
$extractor::$extractComments = true;
$extractor::$textDomain = $textDomain;
$translatable = $extractor->fromDirectory($targetTheme->get_stylesheet_directory());
// todo B fetch and merge translations from po file
$translatable->setDomain($textDomain);
$translatable->ksort();
// skeleton created
// file name is same as the slug which is a common way if you look at twenty* themes.
$skeletonBasename = $targetThemeSlug . '.' . $input->getOption('format');
if ('po' == $input->getOption('format')) {
// po templates have the pot extension in the filename
$skeletonBasename .= 't';
}
// merge with existing template
$skeletonPath = $langPath . '/' . $skeletonBasename;
$extractMethod = 'from' . ucfirst($input->getOption('format')) . 'File';
/** @var Translations $skeletonTranslation */
$skeletonTranslation = call_user_func(['\\Gettext\\Translations', $extractMethod], [$skeletonPath]);
$this->sanitizeTranslation($translatable, $textDomain, $targetTheme->get_stylesheet_directory());
$skeletonTranslation->mergeWith($translatable, $translatable::MERGE_ADD | $translatable::MERGE_REFERENCES);
$this->writeTranslation($input, $output, $skeletonPath, $skeletonTranslation);
$this->updateTranslations($input, $output, $targetTheme, $skeletonTranslation, $textDomain);
}
示例3: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$serverSection = $input->getOption('server');
$config = new \Zend_Config_Ini('config.ini', $serverSection);
$server = $config->server;
if (!isset($server->host)) {
throw new \Exception("Invalid server settings for section '{$serverSection}': host is required");
}
if (isset($server->user)) {
$host = $server->user . '@' . $server->host;
} else {
$host = $server->host;
}
if (isset($server->port)) {
$host .= ' -p ' . $server->port;
}
if (isset($server->dir)) {
$cmd = "cd " . $server->dir . ';';
}
$gitEnvVars = "GIT_AUTHOR_NAME=" . escapeshellarg(isset($_ENV['GIT_AUTHOR_NAME']) ? $_ENV['GIT_AUTHOR_NAME'] : trim(`git config user.name`)) . " GIT_AUTHOR_EMAIL=" . escapeshellarg(isset($_ENV['GIT_AUTHOR_EMAIL']) ? $_ENV['GIT_AUTHOR_EMAIL'] : trim(`git config user.email`)) . " GIT_COMMITTER_NAME=" . escapeshellarg(isset($_ENV['GIT_COMITTER_NAME']) ? $_ENV['GIT_COMITTER_NAME'] : trim(`git config user.name`)) . " GIT_COMMITTER_EMAIL=" . escapeshellarg(isset($_ENV['GIT_COMITTER_EMAIL']) ? $_ENV['GIT_COMITTER_EMAIL'] : trim(`git config user.email`));
$cmd .= $gitEnvVars . ' ';
$cmd .= "exec bash";
$cmd = "ssh -t {$host} " . escapeshellarg($cmd);
if ($output->isDebug()) {
$output->writeln($cmd);
}
$ret = null;
passthru($cmd, $ret);
exit($ret);
}
示例4: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$manifest = Manifest::download($this->pharUpdateManifestUrl, $output->isDebug());
$manager = new Manager($manifest, $this->getLocalFilesystem());
!$this->logger ?: $manager->setLogger($this->logger);
$currentVersion = $this->getApplication()->getVersion();
$newVersion = null !== $input->getArgument('version') ? $input->getArgument('version') : null;
$major = $input->getOption('major');
// Lock to current major version?
$pre = true;
//Allow pre-releases?
if (false === $manager->update($currentVersion, $major, $pre, $newVersion, $output->isDebug())) {
return self::EXIT_ERROR;
}
return self::EXIT_SUCCESS;
}
示例5: run
/**
* Runs an external process.
*
* @param OutputInterface $output An OutputInterface instance
* @param string|array|Process $cmd An instance of Process or an array of arguments to escape and run or a command to run
* @param string|null $error An error message that must be displayed if something went wrong
* @param callable|null $callback A PHP callback to run whenever there is some
* output available on STDOUT or STDERR
* @param int $verbosity The threshold for verbosity
*
* @return Process The process that ran
*/
public function run(OutputInterface $output, $cmd, $error = null, $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)
{
$formatter = $this->getHelperSet()->get('debug_formatter');
if (is_array($cmd)) {
$process = ProcessBuilder::create($cmd)->getProcess();
} elseif ($cmd instanceof Process) {
$process = $cmd;
} else {
$process = new Process($cmd);
}
if ($verbosity <= $output->getVerbosity()) {
$output->write($formatter->start(spl_object_hash($process), $this->escapeString($process->getCommandLine())));
}
if ($output->isDebug()) {
$callback = $this->wrapCallback($output, $process, $callback);
}
$process->run($callback);
if ($verbosity <= $output->getVerbosity()) {
$message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode());
$output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful()));
}
if (!$process->isSuccessful() && null !== $error) {
$output->writeln(sprintf('<error>%s</error>', $this->escapeString($error)));
}
return $process;
}
示例6: buildProcess
/**
* Build Process instance for each testcase file
*
* @param string $fileName
* @param array $phpunitArgs
* @return Process
*/
protected function buildProcess($fileName, array $phpunitArgs = [])
{
$processBuilder = new ProcessBuilder();
$dispatcher = $this->command->getDispatcher();
$dispatcher->dispatch(CommandEvents::RUN_TESTS_PROCESS, $processEvent = new RunTestsProcessEvent($this->command, $this->input, $this->output, $processBuilder, $phpunitArgs));
$process = $processBuilder->setEnv('BROWSER_NAME', $this->input->getArgument('browser'))->setEnv('ENV', strtolower($this->input->getArgument('environment')))->setEnv('SERVER_URL', $this->input->getOption('server-url'))->setEnv('PUBLISH_RESULTS', $this->input->getOption('publish-results') ? '1' : '0')->setEnv('FIXTURES_DIR', $this->input->getOption('fixtures-dir'))->setEnv('LOGS_DIR', $this->input->getOption('logs-dir'))->setEnv('DEBUG', $this->output->isDebug() ? '1' : '0')->setPrefix(STEWARD_BASE_DIR . '/vendor/bin/phpunit')->setArguments(array_merge($processEvent->getArgs(), [$fileName]))->setTimeout(3600)->getProcess();
return $process;
}
示例7: executeCommandByProject
/**
* {@inheritdoc}
*/
protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
{
$this->getSshExec()->passthru(strtr('cd %project_dir% && /usr/local/bin/sami update sami_config.php' . ($output->isDebug() ? ' -v' : ''), ['%project_dir%' => $projectConfig->getRemoteWebappDir()]));
$localBuildDir = sprintf('%s/build/apidoc', $projectConfig->getLocalWebappDir());
$apiDocIndexFilepath = strtr('%build_dir%/index.html', ['%project_name%' => $projectConfig->getProjectName(), '%build_dir%' => $localBuildDir]);
if (file_exists($apiDocIndexFilepath)) {
$this->openFile($apiDocIndexFilepath);
}
}
示例8: debug
/**
* Creates a debug message.
*/
public function debug($message, \PhpParser\Node $expr = null)
{
if ($this->output->isDebug()) {
$this->output->writeln('[DEBUG] ' . $message);
$this->output->write($this->filepath);
if ($expr) {
$this->output->write(':' . $expr->getLine());
}
$this->output->writeln('');
}
}
示例9: _systemCheckRet
private function _systemCheckRet($cmd, InputInterface $input, OutputInterface $output)
{
$ret = null;
if ($output->isDebug()) {
$output->writeln($cmd);
}
passthru($cmd, $ret);
if ($ret != 0) {
throw new \Exception("command failed");
}
}
示例10: executeCommandByProject
/**
* @{inheritdoc}
*/
protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
{
$remoteReportFilePath = strtr('%build_dir%/%project_name%.html', ['%project_name%' => $projectConfig->getProjectName(), '%build_dir%' => $this->remoteBuildDir]);
// Analyse source project code
$this->getSshExec()->passthru(strtr('mkdir -p %build_dir% && /usr/local/bin/phpmetrics --level=0 --report-html=%report_file% %project_dir%/src' . ($output->isDebug() ? ' --verbose' : ''), ['%report_file%' => $remoteReportFilePath, '%build_dir%' => $this->remoteBuildDir, '%project_dir%' => $projectConfig->getRemoteWebappDir()]));
$localReportFilePath = str_replace($this->remoteBuildDir, $this->localBuildDir, $remoteReportFilePath);
$this->getRemoteFilesystem()->copyRemoteFileToLocal($remoteReportFilePath, $localReportFilePath);
if ($this->getLocalFilesystem()->exists($localReportFilePath)) {
$this->openFile($localReportFilePath);
}
return $this->getSshExec()->getLastReturnStatus();
}
示例11: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$host = $input->getOption('host');
$username = $input->getOption('username');
$password = $input->getOption('password');
//Debug: print received options
if ($output->isDebug()) {
$output->writeln("host=" . $host);
$output->writeln("username=" . $username);
$output->writeln("password=" . $password);
}
}
示例12: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('Get weather info from yandex. CityId = ' . $this->_config['weather']['cityId']);
$info = new \Petun\YaSpeech\Weather\Info($this->_config['weather']['cityId']);
$composer = new \Petun\YaSpeech\Weather\Composer($info);
if ($output->isDebug()) {
$output->writeln('Generated text is ' . $composer->getComposition($this->_config['weather']['composition']));
}
$output->writeln('Send text to yandex speech');
$speech = new \Petun\YaSpeech\Speech\Processor($this->_config['speech']['apiKey'], $this->_config['speech']['speaker'], $this->_config['speech']['emotion']);
$content = $speech->getMp3($composer->getComposition($this->_config['weather']['composition']));
if ($content) {
$fileToSave = $this->_config['cacheDir'] . '/today_weather.mp3';
$output->writeln('Save to file - ' . $fileToSave);
$bytes = file_put_contents($fileToSave, $content);
if ($output->isDebug()) {
$output->writeln('Write ' . $bytes . ' bytes');
}
} else {
$output->writeln('Error while download file');
}
}
示例13: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var ConsoleOutput $output */
$container = $this->getContainer();
$logger = $container->get('logger');
/** @var LocaleRepository $localeRepository */
$localeRepository = $container->get('doctrine')->getManager()->getRepository('OmCmsI18nBundle:Locale');
$aliases = $localeRepository->getActiveAliases();
if ($output->isDebug()) {
$logger->debug('Find aliases', $aliases);
}
$parameters = ['parameters' => ['om_cms_i18n.locale.aliases' => $aliases]];
$filename = $container->getParameter('om_cms_i18n.locale.filename');
$fs = new Filesystem();
$dumper = new Dumper();
$data = $dumper->dump($parameters);
$fs->dumpFile($filename, $data);
if ($output->isDebug()) {
$logger->debug('Dump data', ['filename' => $filename, $data]);
}
if ($input->getOption('cache-clear')) {
$cmd = $this->getContainer()->getParameter('kernel.root_dir') . '/console ';
$inputParameters = ['command' => 'cache:clear', '--env' => $container->getParameter('kernel.environment')];
if ($output->getVerbosity() <= OutputInterface::VERBOSITY_NORMAL) {
$inputParameters['--no-debug'] = null;
}
$cmd .= (new ArrayInput($inputParameters))->__toString();
$process = new Process($cmd);
$process->mustRun(function ($type, $buffer) use($output) {
if (Process::ERR === $type) {
$output->write('<error>' . $buffer . '</error>');
} else {
if ($output->isDebug()) {
$output->write($buffer);
}
}
});
}
}
示例14: executeCommandByProject
/**
* @{inheritdoc}
*/
protected function executeCommandByProject($projectName, ProjectConfiguration $projectConfig, OutputInterface $output)
{
$this->getSshExec()->passthru(strtr('cd %project_dir% && phpspec run --format=%format% --stop-on-failure ' . ($output->isDebug() ? ' --verbose' : ''), ['%format%' => $this->format, '%project_dir%' => $projectConfig->getRemoteWebappDir()]));
$buildDir = $this->remoteBuildDir . '/tests';
$this->getRemoteFilesystem()->mkdir($buildDir);
$report = $this->getSshExec()->exec(strtr('cd %project_dir% && phpspec run --format=html --no-interaction > %build_dir%/unit.html', ['%project_dir%' => $projectConfig->getRemoteWebappDir(), '%build_dir%' => $buildDir]));
$this->getRemoteFilesystem()->syncRemoteToLocal($this->remoteBuildDir, $this->localBuildDir, ['delete' => true]);
$statusCode = $this->getSshExec()->getLastReturnStatus() == 0 && strpos($report, 'broken') === false ? 0 : 1;
if ($this->displayStatusText) {
$output->writeln(sprintf('<comment>Executes unit tests for project "<info>%s</info>"</comment>: %s', $projectName, $statusCode == 0 ? '<info>SUCCESS</info>' : '<error>ERROR</error>'));
}
return $statusCode;
}
示例15: runTests
/**
* @param Process $process
* @param OutputInterface $output
*/
private function runTests($process, $output)
{
if ($output->isDebug()) {
$process->run(function ($type, $buffer) use($output) {
if (Process::ERR === $type) {
$output->write('<fg=yellow>' . $buffer . '</fg=yellow>');
} else {
$output->write($buffer);
}
});
} else {
$process->run();
}
}