Mainstay GitHub

Features

What Mainstay does today

Thirteen parts of one CMS, all running inside your own Laravel application.

Content types are PHP classes

Typed properties with attributes are the schema, the form and the type your editor autocompletes. The class is the type in PHP, mainstay:typescript writes the API's payloads out as TypeScript, and production gets its tables from a migration.

app/Content/Event.php
#[Route('/events/{slug}')]
class Event extends Entry
{
    #[Text(required: true, localized: true)]
    public string $slug;

    #[Date(required: true)]
    public CarbonImmutable $startsOn;

    #[Number(min: 0)]
    public ?int $seats;

    #[Image(sizes: ['card' => [640, 360]])]
    public ?Media $poster;
}

One declaration, read as

its tables event, event_locales
its form /admin
its rules validation
its payload /schema
its type Event

Real columns, kept in step

Every type gets a table of its own, with real columns and constraints. mainstay:sync alters a development database to match once MAINSTAY_SCHEMA_SYNC=true is set, and mainstay:schema:check fails CI when a database has drifted from the classes.

terminal
$ php artisan mainstay:schema:check   ERROR  The database does not match the declared content types.  ⇂ article.glyph: declared, and the column does not exist  ⇂ article.subtitle: in the database, and not declared$ ▍

One query layer, with Gate asked first

Templates, seeders, the admin and the API all read and write through Mainstay::find(), create(), update() and delete(). Filters and sorting are data, not closures, so HTTP carries the same call a template makes.

Blade templates Seeders The admin Content API Mainstay::find() one query layer Gate real tables
resources/views/tag.blade.php
$articles = Mainstay::paginate(Article::class,
    where: ['tags' => $entry->id],
    sort: ['-publishedOn'],
    perPage: 10,
    depth: 1,
);

A page builder made of your classes

Every entry has content: text and the blocks its type allows. The Content tab is the page as your site draws it, each block's fields and images edited in a dialog beside it.

How the page builder works
The Content tab of the admin: this site's front page drawn as the site draws it, its hero selected with the block toolbar above it, and the tree of every block beside it.

Served by Laravel

An entry is served at the path its #[Route] builds, through a Blade template, after every route your app declares itself. No Node on the server. To build the front end elsewhere, set mainstay.site.enabled to false: the app then serves no entries itself, and they are read and written over the API and MCP server behind tokens.

/{slug} page
/blog/{slug} article
/docs/{slug} docs.page
app/Content/Doc.php (abridged)
#[Route('/docs/{slug}')]
#[Template('docs.page')]
class Doc extends Entry
{
    #[Text(required: true, localized: true)]
    public string $slug;
}

Translated per field

A field says whether it is translated. A title gets one value per language; a date or a price stays one, so the languages can never drift apart. Each language is served on a host or a path prefix of its own.

title
ENOpening nightNLPremièreavond
path
/events/opening-night/nl/evenementen/premiereavond
date
12 December 2026 Shared
price
€ 24,00 Shared
config/mainstay.php
'locales' => [
    'en' => 'https://example.com',
    'nl' => 'https://example.com/nl',
],

Images written once

One media library for the installation, with alt text in every language and a focal point. Every size a field declares is written as AVIF and WebP when a file is uploaded, as far as the server's GD can. A size added later is written by mainstay:media:reprocess, which queues the missing copies of every image.

The media library: every image in a grid with its file name, the trash and Upload.
JPEG, PNG, GIF and WebP in AVIF and WebP out every declared size a focal point alt text per language

Relations, tags and globals

Relations are followed to the depth a read asks for. Tags are the entries of a taxonomy, found again through a real pivot. A global holds a site's menu and footer.

depth 0Articleits images, at every depth
depth 1its related articlesits tags
depth 2what those point at
Layout · a global holding the menu and the footerone per site

A target in the trash, or gone, reads as missing and keeps its place, rather than failing the read.

Drafts, history and the trash

A change waits as a draft of what differs until it is published. The last 50 versions an entry replaced can be restored (a setting, or all of them), and a deleted entry waits in the trash.

  1. Draftonly what differs
  2. Publishedin one transaction
  3. Revisionrestorable
A page's history: the version live now, and the one it replaced with Restore beside it, each with who published it.

Accounts and roles

The admin has a sign-in of its own, apart from your site's visitors. Accounts are invited by mail, and a role's capabilities are a grid of the types you register.

The editor role: a grid of capabilities for every entry type, then the taxonomies and globals.

Plugins, switched on by config

A package adds types, blocks, field types, admin screens, listeners and AI providers. Only the plugins your config names load, and their screens answer behind the admin's sign-in and a capability of their own.

Browse plugins
config/mainstay.php
'plugins' => [Acme\Seo\Seo::class],
src/Seo.php
#[Icon('star')]
class Seo extends Plugin
{
    public static function handle(): string
    {
        return 'seo';
    }

    public function types(): array
    {
        return [SeoRedirect::class, SeoSettings::class];
    }

    public function listeners(): array
    {
        return [Published::class => [PurgeCache::class]];
    }
}

An API and an MCP server

The same reads and writes over JSON and as tools a language model calls, behind tokens that never hold more than the account that made them. Without a token, only the types marked #[PublicRead] are read.

Read about the API
/api/mainstay/types the types you may read
/api/mainstay/schema every payload's schema
/api/mainstay/entries/{type} a page of entries
/api/mainstay/path?uri= the entry at an address
terminal
php artisan mainstay:token [email protected] "CI build" --capability=edit_articles
php artisan mainstay:typescript

AI connectors

Every provider laravel/ai speaks, connected on one admin screen. Code prompts with laravel/ai and reaches whatever the site connected, and a plugin adds a provider of its own.

Connect a provider

Its key from the environment, or saved on the screen and encrypted at rest.

manage_connectors

Test it

One word from its cheapest model, or one embedding, with the key kept out of any error.

Choose the defaults

The provider for text, images, speech, transcription, embeddings, reranking and classification.