Lapis Docs

For contributors

API review (v1.0)

This review lists what a site, a plugin or a test touches, and what had to change before it was frozen. After v1.0, only compatible changes are allowed, such as new optional arguments and new methods, so renames and reshapes belonged here.

Surfaces

Surface Where State
Template variables $cms, $page, $site, $attributes see 1, 4, 7
Components <x-block>, <x-repeat>, <x-form>, <x-seo>, <x-importmap> consistent
Page files pages/ layout, [param], [...catchall], [slug].{type}.php, _types/, _404.php, _maintenance.php, _middleware.php, route files consistent
Page functions #[Get] #[Post] #[Put] #[Patch] #[Delete] #[Query] #[Method], #[Middleware] (repeatable), #[Cached], #[Paths], #[CrossSite], #[ApiKey], Webhook::verify(), validate() see 2
Middleware BasicAuth, Cache, Cors, Headers, NoIndex, RateLimit, RequireEditor, RequireRole, Skip consistent. Maintenance and Redirects are built in (see 1)
Config LapisConfig see 3
Definitions Data\Table + Data\Columns\*, Forms\Form + Forms\Fields\*, Settings\Fields\* see 2, 5
Plugins Plugin, Extend (with panel()), BlockType (with fields), Panel, events (Lapis\Events\*) see 6
Editor JS lapis (version, state, h, api, toast, t, registerPanel, registerBlockType) see 8
Helpers Lapis\cms(), setting(), asset(), validate() (texts: Tempest's translate()) consistent
Tests Lapis\Testing\LapisTestCase (state builders, visit, api(), assert*) consistent
Console ./lapis … (Tempest's under ./lapis tempest) done

Findings

Clear fixes (no design choice)

  1. Internals look public. Cms::repeatView(), enterItem(), leaveItem(), blockView(), blockValue() serve the components, and Middleware\Maintenance and Middleware\Redirects run by themselves. Mark them @internal so they are not frozen.
  2. Docblock names a method that does not exist: Cms::imageVariant() says $cms->image(...).
  3. Data\Columns\Slug(from:, label:) is the only definition whose first parameter is not the label. Make it Slug(label: 'Path', from: …) (named arguments keep working).

Decisions

  1. LapisConfig arrays → config objects (as the definitions already are): imageSizes: ['card' => new ImageSize(640, 480, fit: 'cover')], schema: new SchemaOrg(type: 'Bakery'), ogImage: new OgImageStyle(background:, color:, accent:), turnstile: Turnstile::fromEnv() (the keys in .env). Today these are untyped arrays whose keys only the docs know.
  2. Three Text classes. validate() in page functions takes Data\Columns, while forms use Forms\Fields and settings Settings\Fields. A page form that validates with data columns imports the "wrong" family. Proposal: validate() also accepts Forms\Fields (and the docs show those first). The families stay separate, because their options differ (index/unique, placeholder/autocomplete, group/default).
  3. Event names: most are NounPastVerb (PageCreated, MediaDeleted), some are not: Uploaded → MediaUploaded, Published → BlocksPublished, Discarded → DraftsDiscarded. EditorStateBuilding (a hook while building) stays.
  4. $page is mutable. Page's properties are public and writable, so a template can change $page->title for everything rendered after it. Make them readonly.
  5. Editor JS lapis.state is the editor's whole internal state (including the CSRF token and panel data), and the example plugin reads and writes lapis.state.settings.values. Freeze a small surface instead: lapis.user, lapis.locale, lapis.page, lapis.can(ability), lapis.plugin(name) (data from EditorStateBuilding::plugin()), lapis.settings.get(key) and lapis.settings.set(key, value) (saves), and keep state out of the API.
  6. Cms::editing() next to Cms::isEditor(): renamed to isEditing() (signed in and edit mode on).

Marked internal after the review (2026-11-27)

The classes behind the frozen surfaces are @internal: View\BlockView, Content\BlockTypes, BlockKind, BuiltInBlock, PluginBlock, Support\HtmlSanitizer, SafeUrl, Html, Http\EditorApi, Auth\User (the Tempest model behind sign-in: sites and plugins use Auth), and Validation\ValueType with its rules (Validation\Rules\*). A plugin reaches block types through BlockType and templates through <x-block>. These classes may change in a minor version.

Added before v1.0

Before the first release, these public pieces were finalized on top of the table above:

  • LapisConfig::$captcha (Lapis\Forms\Captcha, with Turnstile, HCaptcha, ReCaptcha and FriendlyCaptcha) replaced turnstile:.
  • Data\Records::paginate() returns Tempest's PaginatedData.
  • data-lapis-fragment returns a single marked element to htmx requests targeting it.
  • Events\AssetsCompiling and Events\DoctorChecking let plugins hook into ./lapis assets:compile and ./lapis doctor, and Events\PageRendered adds addToHead() and addToBody().
  • Lapis\SiteCodeWasInvalid is thrown on invalid config, table, form or plugin definitions.
  • Plugins may ship lang/messages.<locale>.yml and components/x-*.view.php alongside src/, discovered automatically.

Not changing

  • Middleware constructor names (ttl, seconds, max) read naturally where they are used.
  • The Form styling parameters (submitClass, successClass, successTitleClass) stay flat, because grouping them buys little.
  • ApiKey('ENV_NAME') default LAPIS_API_KEY.