Relayer
Relayer — PHP full-stack framework

Not Web MVC.Component-based PHP.

Relayer is a convention-first PHP full-stack framework inspired by the Next.js App Router. The directory tree is the URL space, and every route is written not as a controller but as a component that returns an element tree. Routing, APIs, server actions, authentication, caching and the database are wired into a single boot entry. No build step.

$composer require polidog/relayer
Language
PHP 8.5+
Build
No build step
License
MIT
Fig.01src/Pages/hello/[name]/page.psx
<?php

use Polidog\Relayer\Router\Component\PageContext;
use Polidog\UsePhp\Html\H;

return function (PageContext $ctx): Closure {
    $ctx->metadata(['title' => 'Hello']);

    return fn () => (
        <main className="p-8">
            <h1>Hello, {$ctx->params['name']}</h1>
        </main>
    );
};
GET /hello/world200 OK

That closure is the page component. Save the file and /hello/world responds — nothing to register, nothing to configure.

Fig.02Placement is the URL
src/Pages/page.psx/
src/Pages/docs/[slug]/page.psx/docs/http-cache
src/Pages/api/search/route.php/api/search
src/Pages/sitemap.xml/route.php/sitemap.xml
src/Pages/middleware.phpevery route

That is this site’s own src/Pages. There is no routing configuration file.

Legend.psx and the file conventions
.psx
The extension that lets you write JSX inside PHP. use-php compiles it to plain PHP, so there is no template language and no Node build in the middle.
page.psx / route.php
A directory with a page.psx is a page; one with a route.php is a JSON API. Never both in the same directory.
[slug]
A bracketed directory is a dynamic segment, read back as $ctx->params['slug'].
Fig.03The path of a request

A request passes through four places, and no others: shared work in the middleware, rendering in the page, cache headers, then the document that goes out.

GET /docs/http-cache
  1. src/Pages/middleware.phplocale + shared headers
  2. src/Pages/docs/[slug]/page.psxPSX to an element tree
  3. $ctx->cache(…)attaches ETag and s-maxage
  4. HtmlDocumentassembles the head, renders
200 OK — text/html
ColophonThis site
Runtime
FrankenPHP single binary / PHP 8.5
Image
192 MB, 700 ms cold start
Content
Turso (libSQL) — the single source of truth
Edge
Fly.io nrt + Cloudflare cache

This documentation site is itself written in Relayer, and the source is public. github.com/polidog/relayer-docs

Reading the conventions takes longerthan writing the first page.