Performance: First Laravel application
This affects the initial server response time and how fast the page content is delivered to the browser.
<?php // routes/web.php Route::get('/', function () { return view('welcome'); });
<?php // routes/web.php Route::get('/', function () { $users = App\Models\User::all(); return view('welcome', ['users' => $users]); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Loading all users on homepage | N/A (server-side) | N/A | N/A | [X] Bad |
| Serving simple static view | N/A (server-side) | N/A | N/A | [OK] Good |
routes/web.php file in a new Laravel application?routes/web.php doesphp artisan serve to start the local server.routes/web.php:
Route::get('/', function () {
return 'Hello, Laravel!';
});
What will you see when you visit http://localhost:8000/ in your browser?routes/web.php?
Route::get('/', function {
return 'Welcome!';
});function, causing a syntax error.routes/web.php?date('Y') function returns the current year as a string.return date('Y'); inside the route's closure sends the year as response.date(d) without quotes, returning the day of the month instead of the year.Pass the test and this pattern moves unknown