API
Every class and method in PhlatPage, read from the code itself.
A cheatsheet of the objects you work with in routers, controllers and templates, and the Toolkit's static helpers. Each name links to its full entry: the signature, parameters, return type and the source line it comes from.
The search box finds methods too: type slug for Str::slug() or children for $page->children().
Most used
objects
A page whose view comes from an addon, resolving its views from the addon folder rather than the site.
The application core.
Paths
Addons
Views and fields
- viewNames ( )
- roleNames ( )
- pageView ( string $ref )
- locate ( string $kind, string $ref, string $root )
- qualify ( string $ref, string $root )
- owner ( string $path )
- field ( string $ref, string $root )
- resolveField ( string $key, mixed $value, array $def, array $context )
- fieldtypeTemplate ( string $type, string $name )
- fieldtypeMeta ( string $type )
- fileFields ( string $type )
- fieldtype ( string $type )
- loadType ( string $base, string $name, string $baseClass )
Pages and users
Responses
Every item of one collection field - data with no URL of its own, like comments, likes or tags - in a SQLite database at data/collections/{field}.db.
- atomic ( callable $fn )
- count ( )
- create ( string $parent )
- database ( )
- delete ( string $uuid )
- deleteParent ( string $parent )
- deleteParents ( array $parents )
- find ( )
- get ( string $uuid )
- parents ( )
- reindex ( )
- reparent ( array $uuids )
- save ( string $uuid, array $data )
- sum ( string $field )
- unscoped ( )
A global field definition - its type, label and options - read from fields/{name}/_index.json with its `extends` chain applied.
How one kind of field encodes, decodes, validates and indexes a value.
- absentIsValue ( )
- boundClass ( string $name )
- child ( FieldValue $field, string $key )
- decode ( FieldValue $field )
- empty ( FieldValue $field )
- encode ( FieldValue $field, mixed $raw )
- fromRequest ( Request $request, string $name )
- indexChildren ( FieldValue $field )
- indexValues ( FieldValue $field )
- preview ( FieldValue $field )
- text ( FieldValue $field )
- validate ( FieldValue $field, mixed $raw )
A field as one record holds it: the value with its definition (type, label, options) and where it lives (context).
One entry of a collection field.
Visitor options the server renders: theme, density, a dismissed banner.
A page on the site.
Identity
Fields
Rendering
Tree
A RecordCollection of Page objects.
A File that is publicly visible and knows which page it belongs to.
Manages every file owned by a page/item/user - identified by owner UUID + filename - including its index, public mirror, and image variants.
Variants
Paths
Files
- get ( string $pageUuid, string $filename )
- metaPath ( string $path )
- meta ( string $path )
- build ( string $actualPath, string $pageUuid, string $filename )
- buildImage ( string $actualPath, string $pageUuid, string $filename )
- store ( string $sourcePath, string $name, string $pageUuid )
- upload ( string $tmpPath, string $name, string $pageUuid )
- update ( string $pageUuid, string $filename, array $changes )
- delete ( string $pageUuid, string $filename )
- isPublic ( string $pageUuid, string $filename )
- makePrivate ( string $pageUuid, string $filename )
- forPage ( string $pageUuid )
Serving
Clearing
Maintenance
A PageFile that is an image. transform() (and the src()/srcset() helpers built on it) only compute the target variant URL and record the requested options via Registry::setVariant() : no pixels are touched here.
Base for anything stored as an _index.json + _data.json folder (Page, User).
- assertUnlocked ( )
- create ( App $app, string $path, array $data, callable $make, callable $guard )
- data ( )
- exists ( )
- generateUuid ( App $app )
- index ( )
- isSiteObject ( )
- keyFor ( string $type, string $value )
- name ( )
- objectType ( )
- path ( )
- publishedData ( )
- registryFields ( )
- registryKey ( )
- registryPath ( )
- save ( )
- upload ( array $file )
A lazy, immutable list of records.
- accepts ( Record $item )
- all ( callable $fn )
- any ( callable $fn )
- append ( ?Record $item )
- appendPath ( string $path )
- contains ( Record $item )
- count ( )
- each ( callable $fn )
- filter ( callable $fn )
- first ( )
- getIterator ( )
- import ( array $items )
- isEmpty ( )
- last ( )
- limit ( int $limit )
- nth ( int $index )
- offset ( int $offset )
- paths ( )
- pluck ( string $field )
- reverse ( )
- toArray ( )
- total ( )
SQLite index of every page UUID with its path, view, status and timestamps. find() queries it with the comma-separated DSL.
- allRows ( )
- atomic ( callable $fn )
- boot ( )
- countRows ( )
- deleteSubtree ( string $subtree )
- distinctValues ( string $column )
- find ( )
- gate ( string $path )
- get ( string $uuid )
- index ( Record $object )
- locate ( string $uuid )
- mountOf ( string $view )
- pruneColumns ( )
- rebuild ( )
- remove ( string $uuid )
- rows ( )
- sumRows ( string $query, string $field )
- undeclaredColumns ( )
- updatedAt ( string $path )
The current HTTP request: path segments, query, post body, uploaded files, and whether htmx sent it.
Holds the routes a view registers for its page, plus before and after hooks.
- after ( callable $hook )
- any ( string $pattern, callable $handler )
- before ( callable $hook )
- clearRoutes ( )
- delete ( string $pattern, callable $handler )
- get ( string $pattern, callable $handler )
- patch ( string $pattern, callable $handler )
- post ( string $pattern, callable $handler )
- put ( string $pattern, callable $handler )
Session values and flash messages under one name, so views and addons can't overwrite each other's keys.
The visitor's session as `$app->session`: login, the signed-in user, permissions, CSRF and throttling.
- can ( string $key )
- clearThrottle ( )
- hasCookie ( )
- id ( )
- isLoggedIn ( )
- login ( string $username, string $password )
- loginAs ( User $user )
- logout ( )
- refresh ( User $user )
- regenerate ( )
- requireLogin ( )
- requirePermission ( string $key )
- revoke ( string $username )
- scope ( string $name )
- start ( )
- throttle ( string $key, int $max )
- user ( )
A user account.
toolkit
Array helpers: map, filter, find, sort, pluck and friends.
Inspection
Extraction
Transformation
- range ( int $start, int $end )
- combine ( array $keys, array $values )
- map ( array $array, callable $fn )
- random ( array $values )
- filter ( array $array )
- filterKeys ( array $array, callable $fn )
- partition ( array $array, callable $fn )
- reduce ( array $array, callable $fn )
- unique ( array $array )
- reverse ( array $array )
- flip ( array $array )
- flatten ( array $array )
- setPath ( array $array, array $keys, mixed $value )
Searching
Sorting
Terminal output and input for CLI commands: messages, tables, progress bars and prompts.
- args ( array $args )
- br ( )
- climate ( )
- confirm ( string $prompt )
- docblock ( string $file )
- error ( string $message )
- info ( string $message )
- input ( string $prompt )
- namespaceHelp ( string $namespace, string $dir )
- out ( string $message )
- password ( string $prompt )
- progress ( int $total )
- status ( string $message )
- success ( string $message )
- table ( array $data )
- usage ( string $file )
- wantsHelp ( array $args )
- warning ( string $message )
Color helpers: read any CSS color (#hex, rgb(), hsl() or oklch()) into rgb/hsl, pick a readable text color, lighten and darken.
Conversion
Low-level cookie handling: HttpOnly, SameSite=Lax and Path=/ always, Secure on https.
PDO connection handling and SQL execution, used by the registry.
Directory helpers: list, create, move and delete folders.
Inspection
Contents
Dates and times: now, parse, format, diff and relative "ago" strings.
Creation
Formatting
File helpers: read, write, resolve, copy, symlink and mime type.
Inspection
Path
Read / Write
Operations
Runs git commands against a repository: status, add, commit, log, diff and restore.
Staging & commits
Objects
- resolve ( string $path )
- prefix ( string $path )
- tree ( string $path, string $tree )
- makeTree ( string $path, array $entries )
- hashFiles ( string $path, array $files )
- ignored ( string $path, array $files )
- commitTree ( string $path, string $tree, ?string $parent, string $message )
- advance ( string $path, string $commit, ?string $from, string $message )
- log ( string $path )
- diff ( string $path )
- changed ( string $path, string $from, string $to )
- show ( string $path, string $hash )
- restore ( string $path, string $ref, string $file )
- readFile ( string $path, string $ref, string $file )
Branches
Submodules
Hashing, password hashing and verification, and random tokens.
Outbound HTTP requests returning an HttpResponse.
Sets htmx response headers: redirect, location, refresh, push and replace URL, trigger, retarget and reswap.
Calls a function, matching available values to its parameters by name.
JSON encode and decode.
Signed JSON Web Tokens: RS256 verification against a provider's published keys (its JWKS).
Exclusive file locks that serialize work across PHP processes on one host.
Writes to the PHP error log - stderr under php-fpm, so it lands in the container logs.
Number helpers: format, round, abs, clamp and friends.
Formatting
Runs a command as a child process, array-form so nothing is interpolated into a shell.
The HTTP response: status code, headers, redirects, and sending html or text.
Status
Redirect
Sanitizes untrusted input into clean text, email, url and similar values.
PHP serialize and unserialize.
Low-level PHP session handling.
Lifecycle
Data
Read-only access to server and environment values: host, scheme, ip, headers.
String helpers: case, slug, search, replace, split and join.
Inspection
Extraction
Transformation
- lower ( string $string )
- upper ( string $string )
- base64 ( string $string )
- ucFirst ( string $string )
- title ( string $string )
- slug ( string $string )
- asciiSlug ( string $string )
- camel ( string $string )
- snake ( string $string )
- truncate ( string $string, int $length )
- wordCount ( string $string )
- words ( string $string, int $count )
- repeat ( string $string, int $times )
Removal
Replacement
- replace ( string $string, array|string $search, array|string $replace )
- replaceFirst ( string $string, string $search, string $replace )
- replaceLast ( string $string, string $search, string $replace )
- replaceRegex ( array|string $pattern, array|string $replacement, array|string $subject )
- replaceRegexUsing ( string $pattern, callable $callback, string $subject )
- translate ( string $string, array $map )
Splitting
Parse, build, encode and decode URLs and query strings.
Building
Construction
Validation rules: required, email, length and more, plus check() to collect errors.
Format
- email ( string $value )
- url ( string $value )
- slug ( string $value )
- filename ( string $value )
- variant ( string $value )
- numeric ( mixed $value )
- integer ( mixed $value )
- alpha ( string $value )
- alphanumeric ( string $value )
- date ( string $value )
- match ( string $value, string $pattern )
- allowedExtension ( string $filename, array $allowed )
Range
Comparison
Collector