Getting Started
Install PhlatPage, point a web server at the public folder, and serve your first page.
Requirements
- PHP 8.4
- Composer
- Bun (for Tailwind and JS bundling)
- A web server with its document root pointed at
site/public/
Installation
Clone the repository and install dependencies:
git clone https://github.com/your-org/phlatpage my-site
cd my-site
composer install
bun install
Entry point
The web server document root must point to site/public/. The entry point is site/public/index.php:
<?php
require_once __DIR__ . '/../../vendor/autoload.php';
Phlat::app(dirname(__DIR__))->execute();
dirname(__DIR__) resolves to the project root (the parent of public/) and Phlat::app() returns a singleton App instance for it. execute() resolves the request URL to a page, runs the view router, and renders the response.
Directory structure
my-site/
phlat/ ← framework core (do not edit)
site/
pages/ ← your content
views/ ← templates, routers, and controllers (colocated per view)
fields/ ← global field definitions
fieldtypes/ ← custom field types
addons/ ← site-specific addons
public/ ← web document root
index.php
Creating your first page
Every page is a folder inside site/pages/ containing an index.json (with a uuid) and a data.json. The root page is the site/pages/ folder itself, its URL is /.
The simplest way to create a page is through the admin UI, which mints the uuid and writes both files for you. To create one from code instead, call $page->new($slug, $data), it mints the uuid, writes index.json, then saves $data to data.json in one step:
site/pages/
index.json ← root page
data.json ← renders at /
about/
index.json
data.json ← renders at /about/
blog/
index.json
data.json ← renders at /blog/
my-post/
index.json
data.json ← renders at /blog/my-post/
Local development
bun run watch # Tailwind watch mode
bun run sync # BrowserSync dev server
BrowserSync proxies your local PHP web server and reloads the browser on template and content changes.
<?php
require_once __DIR__ . '/../../vendor/autoload.php';
Phlat::app(dirname(__DIR__))->execute();