Created
February 12, 2018 10:20
-
-
Save dmaicher/61f2e388ac0e65cc945dbb6e678e2ef7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?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