8000 [FrameworkBundle] Show server:run logs by default by nicolas-grekas · Pull Request #19174 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Show server:run logs by default #19174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
8000
Diff view
Diff view
[FrameworkBundle] Show server:run logs by default
  • Loading branch information
nicolas-grekas committed Jun 25, 2016
commit 7cc6161c765fe4e8b20c664049391d92c0b591f0
22 changes: 17 additions & 5 deletions src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
8000
Original file line numberDiff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessBuilder;
use Symfony\Component\Process\Exception\RuntimeException;

/**
* Runs Symfony application using PHP built-in web server.
Expand Down Expand Up @@ -113,14 +116,23 @@ protected function execute(InputInterface $input, OutputInterface $output)
$builder->setWorkingDirectory($documentRoot);
$builder->setTimeout(null);
$process = $builder->getProcess();
$callback = null;

if (OutputInterface::VERBOSITY_VERBOSE > $output->getVerbosity()) {
if (OutputInterface::VERBOSITY_NORMAL > $output->getVerbosity()) {
$process->disableOutput();
} else {
try {
$process->setTty(true);
} catch (RuntimeException $e) {
$callback = function ($type, $buffer) use ($output) {
if (Process::ERR === $type && $output instanceof ConsoleOutputInterface) {
$output = $output->getErrorOutput();
}
$output->write($buffer, false, OutputInterface::OUTPUT_RAW);
};
}
}

$this
->getHelper('process')
->run($output, $process, null, null, OutputInterface::VERBOSITY_VERBOSE);
$process->run($callback);

if (!$process->isSuccessful()) {
$errorMessages = array('Built-in server terminated unexpectedly.');
Expand Down
0