This site is built with Viewi itself. It is experimental and still in development. If you see any bugs please do not hesitate and open an issue or DM me on Twitter.

Tour of Heroes

Step 3 - Home Page

When you open a browser, you will see some content already.

The code for this page is located here:


and here:


As you can see, the component itself is a PHP class that extends the BaseComponent abstract class. The component is tightly coupled with the template file, which has the same base name. To create a new Viewi component, you will need to create two files with the same base name: one for PHP and another for HTML template.

To output something in the template file, you can use interpolation.:

<div>$title</div> - will render $title property from your component inside of a div.

More about a template syntax here: /docs/syntax .

Let's change the title on our home page:


public string $title = 'Tour of Heroes';

When you refresh the page, you will see a new title.

Next step