Skip to content

Instantly share code, notes, and snippets.

@dmaicher
Created February 12, 2018 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmaicher/61f2e388ac0e65cc945dbb6e678e2ef7 to your computer and use it in GitHub Desktop.
Save dmaicher/61f2e388ac0e65cc945dbb6e678e2ef7 to your computer and use it in GitHub Desktop.
<?php
require_once 'vendor/autoload.php';
$kernel = new AppKernel('prod', false);
$kernel->boot();
$router = $kernel->getContainer()->get('router');
$routes = $router->getRouteCollection();
$router->getContext()->setMethod('GET');
$hosts = [
// all my app's hosts
];
$totalMatchedRoutes = 0;
foreach ($hosts as $host) {
$router->getContext()->setHost($host);
foreach (range(0, 5000) as $i) {
/** @var \Symfony\Component\Routing\Route $route */
foreach ($routes as $route) {
if (!$route->getCondition() && (!$route->getMethods() || in_array('GET', $route->getMethods()))) {
try {
$router->match(preg_replace('/\{[^{]+\}/', 'foo', $route->getPath()));
$totalMatchedRoutes++;
} catch (\Symfony\Component\Routing\Exception\ResourceNotFoundException $e) {
}
}
}
}
}
echo $totalMatchedRoutes.PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment