routes, resources and public
Lendly needs a URL for its book list, a template to draw it, a stylesheet and a logo. Each belongs in a different folder, and one of those folders is special: it is the only one the internet can see.
The rule
routes/ decides, resources/ is raw, public/ is served.
routes/: which URL runs which code.
routes/web.php: browser routes. They get sessions, cookies and CSRF protection.routes/console.php: your own Artisan commands and scheduled tasks. These are not web pages.routes/api.php: stateless JSON routes, prefixed with/api. A new app does not have it.php artisan install:apicreates it.
// routes/web.php
Route::get('/books', function () {
return view('books.index');
});resources/: raw material. Nothing here is sent to the browser as is.
resources/views/: Blade templates.view('books.index')meansresources/views/books/index.blade.php, with the dot standing for a folder.resources/css/andresources/js/: source files that Vite compiles intopublic/build/.
public/: the web root. The web server points here, so it is the only folder with a URL. It holds index.php, the favicon, robots.txt, Vite's built files, and any fixed images you add. public/images/logo.png is served at /images/logo.png.
Because only public/ is exposed, your .env, models and config sit safely one level up, out of reach.
The shortcut
Ask "does the browser fetch this file as it is?" Yes → public/. No, something processes it first → resources/. It is a URL rule, not a file → routes/.
Book list template
Blade must be rendered first, so
resources/views/books/index.blade.php.
The trap is editing files in public/build/. Vite overwrites them on every build. Edit the source in resources/.
Drills
Answer fast — trust the rule.
Which file does view('loans.history') render?
A static robots.txt should be reachable at /robots.txt. Where does it go?
What belongs in routes/console.php?
You change a colour in public/build/assets/app-3f9a.css and it disappears later. Why?
Remember
routes/decides,resources/is raw,public/is served.- Fetched as it is →
public/; processed first →resources/; a URL rule →routes/. - Trap: never edit
public/build. Edit the source inresources/.
