Skip to content
Greg Bowler edited this page May 18, 2026 · 3 revisions

A page view is the HTML that represents the response sent back to the browser. It stays as HTML on disk rather than being assembled from PHP string output.

That separation is important because it means the page can be designed, read, and reviewed as a document in its own right.

Static HTML as the starting point

The simplest useful page view is just a normal HTML file. We can open it in an editor, write the structure we want, and serve it immediately.

That is helpful while prototyping because the first version of a page can be built and discussed as plain markup. Later, the same file can become production code by adding page logic, components, partials, and binding.

Default placeholder content can stay in the HTML too. Later, when data is bound into the document, those default values can be replaced. Until then, the file can still read well and make sense on its own.

For example:

<h1>User profile</h1>

<p>Display name: <span data-bind:text="displayName">none given</span></p>

If there is no displayName bound to the HTML, the page displays the default message "none given", just as it would do without using a framework.

How views are loaded

When a request matches a route, WebEngine loads the matching view file from page/. In many cases that is just one file, but a full response may also include:

Those features still result in one final HTML document, but they allow the source views to stay smaller and easier to maintain.

Good practices for page views

Keep page views semantic and readable. Write the HTML so another developer can understand the page structure without needing to read the PHP first.

It also helps to design the page shape before adding logic. Once the structure is visible in HTML, it is much easier to decide which parts need binding, which parts need reusable components, and which parts should stay static.

Connecting page views to page logic

There are three methods of connecting a view to its logic:

  1. data-bind attributes in HTML - this allows automatic hydration of pages where the HTML defines the shape and PHP defines the data, binding data to the DOM automatically.
  2. Form do buttons - if a button has the name do, its value is used to execute a PHP function when clicked. This is covered in page logic.
  3. Direct DOM manipulation of the page from PHP.

When views need to be made dynamic, we'll use page logic.

Clone this wiki locally