codeatlas / analyzer-routes
CodeAtlas route analyzer — extracts Laravel routes via AST.
v0.1.1
2026-08-22 19:30 UTC
Requires
- php: ^8.3
- codeatlas/contracts: ^0.1.0
- codeatlas/core: ^0.1.0
Requires (Dev)
- pestphp/pest: ^3.5
This package is not auto-updated.
Last update: 2026-08-23 05:46:29 UTC
README
Route analyzer for CodeAtlas. Extracts every route from a Laravel project via AST (never regex, per the constitution) and emits graph nodes and edges.
What it extracts
| Feature | Support |
|---|---|
| HTTP verbs | get, post, put, patch, delete, options, any |
match() |
Multiple verbs per route |
| Actions | [Controller::class, 'method'], Controller::class (invokable), 'Controller@method', closures |
| Route names | ->name() + group name prefixes |
| Middleware | ->middleware() (string + array) + group inheritance |
| Constraints | ->where(), ->whereNumber(), ->whereAlpha(), ->whereAlphaNumeric(), ->whereUuid() |
| Domains | ->domain() + group domains |
| URI parameters | {id}, {slug?} extraction |
| Groups (fluent) | Route::prefix()->middleware()->group(fn) |
| Groups (array) | Route::group(['prefix' => ..., 'as' => ..., 'middleware' => ...], fn) |
| Nested groups | Prefixes concatenate, middleware accumulates, names concatenate |
resource() |
Expands to 7 routes (index/create/store/show/edit/update/destroy) |
apiResource() |
Expands to 5 routes (no create/edit) |
Output
For each route:
- one Route node (
NodeType::Route) with full metadata perJSON_SCHEMA.md - one Route → Controller edge (
EdgeType::RoutesTo) when the handler is a controller - one Route → Middleware edge (
EdgeType::UsesMiddleware) per applied middleware
Fault isolation
A malformed route file is logged, recorded as an AnalysisError (warning severity), and skipped — the remaining files are still analyzed. This is the constitution's per-file fault-isolation guarantee.
Architecture
RouteAnalyzer
└─ RouteExtractor (context-aware AST descent, group stack)
├─ ChainUnwinder (flattens fluent chains → ordered operations)
├─ ValueResolver (extracts string/array/class-const literals)
└─ ActionResolver (controller | invokable | closure | string@method)
Installation
composer require codeatlas/analyzer-routes
Part of the CodeAtlas monorepo. MIT © Snova Labs.