How routes are read
Nimbus builds its route list and request forms from your application code. This page explains how, so you know what to expect.
What Nimbus reads
Nimbus asks the Laravel router for the routes that match your route prefix. For each route, it opens the source file of the controller and reads it as text. It follows the form request, the resources, and the data objects that the controller method uses.
From these files it learns:
- The validation rules of the request, including rule objects and form request hooks.
- The query parameters that a
GETcontroller reads. - The middleware of the route, such as authentication and throttle.
- The shape of JSON responses.
When your code runs
Nimbus reads most details from your source files. To get validation rules and field types, it also creates form requests, calls their rules() method and reads your database table columns. Avoid side effects in these places. A slow rules() method slows the route list, because Nimbus waits for it and has no timeout. The routes snapshot saves the result, so the list is read only once.
What this means for you
- Rules that depend on the current request, such as the signed in user, may be missing.
- A route that Nimbus cannot read stays in the list and shows an extraction error. The other routes load as usual. Examples are a missing controller method, an abstract form request, or a form request that needs constructor arguments.
- When
rules()throws, Nimbus reads the rules from the source file instead. It shows the error and keeps the rules it found. - Rules written inline with
validate()in the controller are detected too. - If you use OpenAPI files, Nimbus reads those instead. See OpenAPI.
Large applications can take time to read. Use the routes snapshot to save the result.