Last active
June 12, 2024 18:51
-
-
Save thinkstylestudio/47fa8d52f1c8b34cd14d6d6e8db500f4 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 artisan route:list --path=api --json | jq -r '.[] | select(.name != null) | .name' |
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 | |
$dir = 'tests/Feature'; | |
$files = scandir($dir); | |
$routeNames = []; | |
foreach ($files as $file) { | |
if ($file === '.' || $file === '..') { | |
continue; | |
} | |
$filePath = $dir . '/' . $file; | |
$fileContent = file_get_contents($filePath); | |
preg_match_all("/route\('([^']*)'\)/", $fileContent, $matches); | |
foreach ($matches[1] as $match) { | |
$routeNames[$match] = true; | |
} | |
} | |
$routeNames = array_keys($routeNames); | |
print_r($routeNames); |
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 | |
$apiFileContent = file_get_contents('routes/api.php'); | |
$httpVerbs = ['get', 'post', 'put', 'patch', 'delete', 'options']; | |
$routeCounts = array_fill_keys($httpVerbs, 0); | |
$routePaths = array_fill_keys($httpVerbs, []); | |
foreach ($httpVerbs as $verb) { | |
preg_match_all("/Route::{$verb}\('([^']*)'/", $apiFileContent, $matches); | |
$routeCounts[$verb] = count($matches[0]); | |
$routePaths[$verb] = $matches[1]; | |
} | |
print_r($routeCounts); | |
print_r($routePaths); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment