Routes snapshot
Route extraction can be slow on large apps. The snapshot stores the extracted routes on disk and reuses them while nothing they depend on changed. It is off by default. A user turns it on with snapshot in config/nimbus.php.
The flow
Load the routes
ExtractRoutesActionChecks the nimbus.snapshot setting.State of the snapshot
OffExtracts the routes every time.
FreshReturns the stored routes.
Stale or brokenExtracts the routes and saves a new manifest.
Routes
ManifestManager decides whether the stored manifest is stale.
What the manifest holds
The manifest lives under vendor/sunchayn/nimbus/storage. It stores the extracted routes and the facts they were built from.
- A fingerprint of the config of the active application.
- A fingerprint of the registered routes.
- The size and modification time of every app class file read during extraction.
- The creation time of the manifest.
The AST module fires a ClassFileResolved event whenever it reads a class file. ManifestManager::trackFile listens to it, so every file that shaped the result is tracked. Files under vendor are skipped because the lock file covers them.
When a snapshot is stale
- There is no manifest or it is invalid.
- The config or the route list changed.
- A tracked file changed in size or time, or was removed.
- A tracked file was modified within two seconds of the snapshot. Without a content hash, a recent file cannot be trusted.
Working on it
- Any new code that reads a host class must go through the AST actions or queries, so the file is tracked.
- A change to the stored shape needs the manifest validation to reject old manifests.
php artisan nimbus:snapshot:clearremoves the stored snapshots of all applications. In the workbench, runcomposer nimbus nimbus:snapshot:clear.
See route extraction for the work the snapshot saves.