Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Request–Response Flow and Project Folders  ›  Lesson

routes, resources and public

Routes 12 minroutes/ maps URLs to code, resources/ holds the raw views, CSS and JavaScript that get compiled or rendered, and public/ is the only folder the browser can reach directly.

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:api creates 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') means resources/views/books/index.blade.php, with the dot standing for a folder.
  • resources/css/ and resources/js/: source files that Vite compiles into public/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/.

Placing Lendly's filesStep 1 of 4
  1. 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.

quick drill

Which file does view('loans.history') render?

quick drill

A static robots.txt should be reachable at /robots.txt. Where does it go?

quick drill

What belongs in routes/console.php?

quick drill

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 in resources/.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainRaw versus served

Explain the difference between resources/ and public/ in Lendly, using a Blade view, a CSS file and an uploaded logo as examples. Then say what routes/web.php and routes/console.php are each for.