Flat-file PHP CMS. Built on HATEOAS.

Pages are folders of JSON in git, queries run on a SQLite index, and HTMX drives the interface.

site/pages/
site/pages/
  about/
    _index.json     # uuid, view, metadata
    _data.json      # title, body, whatever fields you add
  blog/
    hello-world/
      _index.json
      _data.json

The setup you no longer write

Fonts

  • Download the font files
  • Write @font-face rules
  • Add preload tags
{include '@fonts/fonts.latte'}

Images

  • Resize every upload
  • Export each size
  • Delete the old ones
<img src="{$page->hero->src('w=800,h=400,fit=crop')}">

Queries

  • Run a database server
  • Write migrations
  • Back it up
{foreach $page->find('view=article,sort=-updated,limit=4') as $post}

Partial updates

  • Add an API route
  • Return JSON
  • Render it again in JavaScript
<div 
	hx-get="{$page->url()}:latest" 
	hx-trigger="load"
></div>

Caching

  • Pick a cache store
  • Name the keys
  • Clear them on every save
{fragment 'latest', cache: 600}

History

  • Add content versioning
  • Keep an audit log
git log --oneline site/pages

HATEOAS

Every route returns HTML. HTMX drives all interactions. The URL pattern is the API: no JSON layer, no client-side routing, no state management.

Files & Folders

Every page is a folder, every field a key in a JSON file. No database server to run, no migrations, no SQL to write.

Override system

Everything in phlat/ is a default. Drop a matching file in site/ and it takes precedence. No configuration required.

Version controlled

Pages are plain files in git. Every dash save is a commit, so a page edit rolls back like any commit.

Three files from idea to page

  1. 1

    Make a folder

    A page is a folder. Its content is a JSON file you can open in any editor.

    // site/pages/hello/_data.json
    {
        "title": "Hello",
        "body": "Written in **any** editor."
    }
    
  2. 2

    Pick a view

    The page names a view, and the view's template renders it.

    {* site/views/note/index.latte *}
    <h1>{$page->title}</h1>
    <div class="prose">
        {$page->body|render}
    </div>
    
  3. 3

    Open the URL

    The folder path is the URL. Each save from the dash is a commit. This is the real page, loaded from /hello:note.

    /hello

Start from the defaults or build every piece

Lean on the defaults

The dash, login and roles, UI components, icons, fonts and a template for every field ship ready to use. Wire them together and a prototype or a small web app runs without writing CSS or a single route.

{* site/views/tasks/index.latte *}
<h1>{$page->title}</h1>
{$page->body|render}
{ui list, items: $page->children() /}
{ui button,
	title: 'New task',
	icon: 'plus',
/}

Build it your own way

Every default is a file you can replace. Write your own views, routers and fieldtypes, or override one shipped template at a time. Nothing in the front end is forced on you, so a fully custom site starts from a blank page.

// site/views/shop/router.php
return function (App $app, Page $page): void {
    $page->router->get('', fn() => $page);
    $page->router->post('cart', fn() => ...);
};

// site/views/@ui/button.latte replaces the shipped button

Every folder is a page, and its path is the URL

The URL is the API

Every block of a page has its own URL. HTMX asks for it and swaps the HTML in. No JSON, no client state.

GET /updates:updates
Releases

Quick start

Create a project from the starter template. The Quickstart walks through it and builds a first page.

terminal
composer create-project phlat/template my-site

Addons

The dash, the UI components, the fonts and the profiler are addons that ship with PhlatPage. Addons covers what each one does. Addons from the community will be listed at addons.phlat.page.

terminal
phlat addons:install <creator>/<name> <tag>