Add a page
A new signed-in page is two files and two lines. This example adds a "Reports" page.
1. The page
Copy public/dashboard.php to public/reports.php and cut it down:
<?php
declare(strict_types=1);
require __DIR__ . '/../app/bootstrap.php';
allow_methods('GET');
$user = require_auth();
view('pages/reports', [
'title' => 'Reports',
'active' => 'reports',
'user' => $user,
]);
require_auth() is the line that makes it private. Leave it out and the page is public.
2. The template
Create app/views/pages/reports.php:
<section class="panel">
<header class="panel-header">
<h2>Reports for <?= e($user['name']) ?></h2>
</header>
<div class="panel-body">
<p class="muted">Nothing to report yet.</p>
</div>
</section>
The layout (sidebar, top bar, flash messages) is added around it automatically. Note the e() around the name: a user's name is user input.
3. The menu link
In app/views/layouts/app.php, add a line to $nav:
'reports' => ['label' => 'Reports', 'href' => 'reports.php'],
4. The icon
In the same file, add an entry to $icons with the same key. Each icon is the inside of a 24 by 24 SVG:
'reports' => '<path d="M3 3v18h18M7 15l4-4 3 3 5-6"/>',
Open reports.php in the browser. It's in the sidebar, highlighted, and a signed-out visitor is sent to the sign-in page.
A public page
For a page anyone can see (pricing, terms), skip require_auth() and pass 'auth' as the layout, which gives the centred card used by the sign-in page:
view('pages/terms', ['title' => 'Terms'], 'auth');
For a full marketing site, most people run a separate site and link to the app.