Quickstart
On this page
Pre-release
Installing PhlatPage requires an invite.
Requirements
- PHP 8.4+ with
pdo_sqlite,imagick, and Composer git- Node.js and npm (to rebuild CSS)
Debian stable
PhlatPage targets compatibility with the latest Debian stable: the PHP and SQLite versions it ships are the minimum, and nothing newer is required.
Install
Create a project from the starter template. It installs the framework into vendor/ and gives you a minimal site/ with a home page, one child page, the dash and a built theme. site/ is yours to edit: your code, config and content.
The template is not on Packagist yet, so register its repository with Composer once per machine:
composer config -g repositories.phlat-template vcs ssh://[email protected]/phlat/template.git
Then create the project:
composer create-project phlat/template my-site
cd my-site
Install manually
To skip the template, add PhlatPage to an empty folder as a Composer package. The framework installs into vendor/ and you create the site/ folder yourself. Register the repository and require the package:
mkdir my-site
cd my-site
composer config repositories.phlat vcs ssh://[email protected]/phlat/page.git
composer require coheredigital/phlatpage
mkdir -p site/public site/pages site/views/default
Add the entry point. The web server's document root must be site/public/:
<?php
// site/public/index.php
$public = $_SERVER['DOCUMENT_ROOT'];
require_once dirname($public, 2) . '/vendor/autoload.php';
Phlat::app(dirname($public))->execute();
Add a config that turns on password sign-in, and a view for the home page:
echo '{"auth": {"password": true}}' > site/config.json
// site/views/default/index.json
{
"fields": {
"title": { "type": "@phlat/text", "label": "Title" },
"body": { "type": "@phlat/markdown", "label": "Body" }
}
}
{* site/views/default/index.latte *}
<!DOCTYPE html>
<title>{$page->title}</title>
<h1>{$page->title}</h1>
{$page->body|render}
The home page is the one page you write by hand, because there is no parent to create it from. Generate its uuid with vendor/bin/phlat uuid:generate:
// site/pages/_index.json
{
"uuid": "<generated uuid>",
"view": "default",
"published": true
}
Stamp its dates and mount the dash by creating a page with its view:
vendor/bin/phlat registry:check --heal
vendor/bin/phlat make:page admin --view=@dash --hidden --publish
Unlike the template, this setup has no built theme. Style the view as you like, or copy the template's site/assets/ and site/pages/assets/ folders to use its Tailwind build.
Create your first account
vendor/bin/phlat user:create alex --role=admin
php -S localhost:8000 -t site/public site/public/index.php
The password is prompted for. Sign in at http://localhost:8000/@users/login.
Alias the CLI
Add `alias phlat='vendor/bin/phlat'` to your `~/.bashrc` (or `~/.zshrc`) and run `phlat user:create alex --role=admin` from the project root.
Create a view
A view is the template that renders a page. Add one called note:
{* site/views/note/index.latte *}
{layout 'layout.latte'}
{block main}
<article>
<h1>{$page->title}</h1>
<div class="prose">{$page->body|render}</div>
</article>
{/block}
Declare its fields
A field is a named value with a type. A view lists the fields it uses in its index.json:
// site/views/note/index.json
{
"fields": {
"title": { "type": "@phlat/text", "label": "Title", "required": true },
"body": { "type": "@phlat/markdown", "label": "Body" }
}
}
Create a page
In the dash, add a page and pick the note view. Or from the terminal:
php phlat/addons/cli/phlat make:page hello --title=Hello --view=note --publish
Open /admin, edit the Hello page, write something in Body and save. The page is at /hello, and its content is in site/pages/hello/_data.json.
A new page is unpublished until you publish it, which --publish does here; in the dash, tick Published on its Settings tab. See Publishing and access.
Local development
npm run watch rebuilds the site and ui CSS as you work, and npm run sync runs BrowserSync, which reloads on template and content changes.
Next
See Build for pages, views, fields, files and images in detail.