Getting Started

Install PhlatPage, point a web server at the public folder, and serve your first page.

Requirements

  • PHP 8.4
  • Composer
  • A web server with its document root pointed at site/public/
  • Node.js (for Tailwind and esbuild)

Installation

Clone the repository and install dependencies:

git clone https://github.com/your-org/phlatpage my-site
cd my-site
composer install
npm 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__ . '/../../phlat/index.php';

Phlat::app('site')->execute();

Phlat::app('site') resolves the site/ directory relative to the project root and returns a singleton App instance. 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/        ← your templates
    routers/      ← your route files
    controllers/  ← your view controllers
    fields/       ← custom field types
    public/       ← web document root
      index.php
      styles/
      scripts/

Creating your first page

Every page is a folder inside site/pages/. The root page is the site/pages/ folder itself — its URL is /. Add a data.json with at minimum a title:

site/pages/
  data.json       ← renders at /
  about/
    data.json     ← renders at /about/
  blog/
    data.json     ← renders at /blog/
    my-post/
      data.json   ← renders at /blog/my-post/

index.json is generated automatically on the first request to each page — you do not need to create it manually.

Local development

npm run watch-styles   # Tailwind watch mode
npm run build-alpine   # bundle Alpine.js
npm run sync           # BrowserSync dev server (proxies port 8080)

BrowserSync proxies FrankenPHP running on port 8080 and reloads the browser on template and content changes.

<?php

require_once __DIR__ . '/../../phlat/index.php';

Phlat::app('site')->execute();