Performance: Resource routes
MEDIUM IMPACT
Resource routes affect the routing system's efficiency and the initial request handling speed in Laravel applications.
Route::resource('posts', PostController::class);
Route::get('/posts', [PostController::class, 'index']); Route::get('/posts/create', [PostController::class, 'create']); Route::post('/posts', [PostController::class, 'store']); Route::get('/posts/{post}', [PostController::class, 'show']); Route::get('/posts/{post}/edit', [PostController::class, 'edit']); Route::put('/posts/{post}', [PostController::class, 'update']); Route::delete('/posts/{post}', [PostController::class, 'destroy']);
| Pattern | Routing Table Size | Route Matching Time | Maintenance Cost | Verdict |
|---|---|---|---|---|
| Manual route definitions for each CRUD action | Large (7 entries per resource) | Higher due to more entries | High, repetitive code | [X] Bad |
| Single resource route definition | Small (1 entry per resource) | Lower due to fewer entries | Low, concise code | [OK] Good |