Created
December 4, 2018 17:54
-
-
Save dfritschy/57d9c009037f021fa706fc4060e5d14a to your computer and use it in GitHub Desktop.
Dump Symfony Routes to yaml File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Dump Routes to YAML File. | |
*/ | |
public function dumpRoutes() | |
{ | |
/** @var $router \Symfony\Component\Routing\Router */ | |
$router = $this->container->get('router'); | |
$collection = $router->getRouteCollection(); | |
$allRoutes = $collection->all(); | |
array_multisort($allRoutes); | |
$output = []; | |
/** @var @Route $route */ | |
foreach ($allRoutes as $name => $route) { | |
if (substr($name, 0, 1) !== "_") { | |
$output[] = "$name:"; | |
$output[] = " path: " . $route->getPath(); | |
$output[] = " controller: " . $route->getDefault('_controller'); | |
$output[] = ""; | |
} | |
} | |
file_put_contents('output.yaml', implode("\n", $output)); | |
return new Response('done'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment