diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php
index 1bc4d0d4639a..b22585755378 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php
@@ -82,8 +82,10 @@ protected function outputRoutes(OutputInterface $output, $routes = null)
$output->writeln($this->getHelper('formatter')->formatSection('router', 'Current routes'));
- $maxName = 4;
- $maxMethod = 6;
+ $maxName = strlen('name');
+ $maxMethod = strlen('method');
+ $maxHostname = strlen('hostname');
+
foreach ($routes as $name => $route) {
$requirements = $route->getRequirements();
$method = isset($requirements['_method'])
@@ -91,20 +93,18 @@ protected function outputRoutes(OutputInterface $output, $routes = null)
? implode(', ', $requirements['_method']) : $requirements['_method']
)
: 'ANY';
+ $hostname = null !== $route->getHostnamePattern()
+ ? $route->getHostnamePattern() : 'ANY';
- if (strlen($name) > $maxName) {
- $maxName = strlen($name);
- }
-
- if (strlen($method) > $maxMethod) {
- $maxMethod = strlen($method);
- }
+ $maxName = max($maxName, strlen($name));
+ $maxMethod = max($maxMethod, strlen($method));
+ $maxHostname = max($maxHostname, strlen($hostname));
}
- $format = '%-'.$maxName.'s %-'.$maxMethod.'s %s';
+ $format = '%-'.$maxName.'s %-'.$maxMethod.'s %-'.$maxHostname.'s %s';
// displays the generated routes
- $format1 = '%-'.($maxName + 19).'s %-'.($maxMethod + 19).'s %s';
- $output->writeln(sprintf($format1, 'Name', 'Method', 'Pattern'));
+ $format1 = '%-'.($maxName + 19).'s %-'.($maxMethod + 19).'s %-'.($maxHostname + 19).'s %s';
+ $output->writeln(sprintf($format1, 'Name', 'Method', 'Hostname', 'Pattern'));
foreach ($routes as $name => $route) {
$requirements = $route->getRequirements();
$method = isset($requirements['_method'])
@@ -112,7 +112,9 @@ protected function outputRoutes(OutputInterface $output, $routes = null)
? implode(', ', $requirements['_method']) : $requirements['_method']
)
: 'ANY';
- $output->writeln(sprintf($format, $name, $method, $route->getPattern()));
+ $hostname = null !== $route->getHostnamePattern()
+ ? $route->getHostnamePattern() : 'ANY';
+ $output->writeln(sprintf($format, $name, $method, $hostname, $route->getPattern()));
}
}