Skip to the workspace
Pebellslearn by building
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.

laravel / routes, resources and public

Explore each scene at your own pace.

01 · The rule

The rule

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.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.