The behavior works; now improve its presentation.
The previous chapter pages repeat the doctype, head, and sometimes navigation. This works, but makes every change riskier. We will share common HTML and give CSS, images, and optional JavaScript clear locations.
A view does three things
Headings, lists, forms, and links in semantic HTML.
Values supplied by the controller, always escaped.
Assembly of small shared partials.
Links to public styles, images, and scripts.
A view does not decide everything
Loop through books, escape a title, choose an HTML element, display an already prepared error.
Query a database, modify the session, decide permissions, or validate a business rule.
The new map
src/views/
├── books/
│ ├── index.php
│ ├── create.php
│ └── edit.php
├── partials/
│ ├── head.php
│ ├── header.php
│ ├── footer.php
│ └── book-form.php
└── errors/
├── 404.php
├── 500.php
└── default.php
public/
├── css/app.css
├── img/logo.svg
└── js/books.jsSUMMARY
What to remember
- The controller prepares; the view presents.
- A partial prevents copying shared HTML.
- Private views stay in src/views.
- Files requested directly by the browser go in public.