Files
ABSDEV/scripts/integration/audit_routes.php
T
2026-10-12 14:27:19 +01:00

18 lines
1.1 KiB
PHP

<?php
/** Static legacy route inventory; does not boot either application or require secrets. */
$root = dirname(__DIR__, 2);
$legacy = $root.'/integration/sonardesk-legacy';
$files = glob($legacy.'/routes/*.php');
foreach (glob($legacy.'/modules/*/Routes/*.php') ?: [] as $file) $files[] = $file;
foreach (glob($legacy.'/modules/*/routes/*.php') ?: [] as $file) $files[] = $file;
sort($files);
$inventory = [];
foreach ($files as $file) {
$contents = file_get_contents($file);
preg_match_all('/Route::(get|post|put|patch|delete|match|any)\s*\(\s*[\'\"]([^\'\"]+)/', $contents, $matches, PREG_SET_ORDER);
foreach ($matches as $m) $inventory[] = ['method'=>strtoupper($m[1]), 'path'=>$m[2], 'source'=>substr($file, strlen($legacy)+1)];
}
$out = $root.'/integration/sonardesk-route-inventory.json';
file_put_contents($out, json_encode(['generated_from'=>'archived SonarDesk source','warning'=>'Static extraction: nested prefixes, resource routes and dynamic registrations require runtime verification','routes'=>$inventory], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)."\n");
fwrite(STDOUT, count($inventory)." static route declarations written to $out\n");