Performance: Route parameters
This affects the server response time and initial page load speed by how routes are matched and parameters are parsed.
Route::get('/user/{id}', function ($id) { // handle request with minimal parameters });
Route::get('/user/{id}/{name}/{age}/{location}/{extra}', function ($id, $name, $age, $location, $extra) {
// handle request
});| Pattern | Route Matching Complexity | Server Processing Time | Impact on LCP | Verdict |
|---|---|---|---|---|
| Many route parameters | High (multiple segments to match) | Higher (more parsing and validation) | Slower LCP due to delayed response | [X] Bad |
| Minimal route parameters | Low (simple pattern) | Lower (less parsing) | Faster LCP with quicker response | [OK] Good |
id in Laravel?Route::get('/post/{postId}', function ($postId) { return 'Post ID: ' . $postId; });, what will be the output when visiting /post/42?Route::get('/product/{id?}', function () { return 'Product ID: ' . $id; });category that defaults to 'all' if not provided, and use it inside the route callback?Pass the test and this pattern moves unknown