Repository navigation
API Data
Caligrafy Quill 2.26.0. Generated from the source by
php qa/build-api-reference.php; the guides explain how to use these classes, this reference says exactly what each public method takes and returns. Back to the API reference.
Models, the query builder, the database connection, migrations, validation and the cache.
| Class | What it is |
|---|---|
Caligrafy\Model |
Class Model is the base model from which the application models can be extended |
Caligrafy\Query |
Builds one SQL statement with bound values only. |
Caligrafy\Database |
The Database class handles all database connections and global functions that interface directly with the database |
Caligrafy\Migrations |
application/migrations/<number>_<name>.sql: php caligrafer.php migrate runs, in number order, the files that never ran on this database, and records each one in caligrafy_migrations (its name, its sha256, when). |
Caligrafy\Validator |
Class that validates inputs |
Caligrafy\Cache |
CACHE_STORE in .env: database (the default with DB_ACTIVATE=true: the caligrafy_cache table, which the deploy step and php caligrafer.php platform install create, shared by the web server, the queue, scheduled jobs and ... |
Caligrafy\Lazy |
#[Caligrafy\Lazy] on a relation method of a model (2.26.0): it may load lazily, without [ERROR 2004] or a warning |
Caligrafy\LazyLoadingException |
Thrown in development when a relation loads lazily on one of several models a query read ([ERROR 2004], 2.26.0) |
Class Model is the base model from which the application models can be extended
Its 24 public methods have a page of their own: Caligrafy\Model.
Builds one SQL statement with bound values only.
Its 47 public methods have a page of their own: Caligrafy\Query.
The Database class handles all database connections and global functions that interface directly with the database
Its 16 public methods have a page of their own: Caligrafy\Database.
namespace Caligrafy;
class MigrationsSource: framework/core/Migrations.php:23
Class Migrations application/migrations/<number>_<name>.sql: php caligrafer.php migrate runs, in number order, the files that never ran on this database, and records each one in caligrafy_migrations (its name, its sha256, when). A file is never run twice: change the database with a new file, not by editing one that ran (status shows it as "changed", and deploy warns). The deploy step (php caligrafer.php deploy) runs them after the create_db.sql scripts. Forward only: undo a change with a new migration.
The statements of a file are split on ; outside quotes and comments. A file stops at its first failing statement: it is not recorded, the statements before it stay applied (MySQL commits a CREATE or ALTER at once), so write each file so that it can run again (IF NOT EXISTS), or keep one change per file.
FOLDER = 'application/migrations'TABLE = 'caligrafy_migrations'PATTERN = '/^(\d{1,14})_([A-Za-z0-9_]+)\.sql$/'
->__construct()->files()Migrations::install()->status()->run()->make()Migrations::statements()
public function __construct($root = '.')No doc comment.
Parameters
-
$root, default'.'
Source: framework/core/Migrations.php:31
public function files()The migration files, in order: name => path (relative to the project)
Source: framework/core/Migrations.php:39
public static function install()Creates the table that records the migrations that ran
Source: framework/core/Migrations.php:65
public function status()Every migration with its state: ran, pending, or changed (it ran, then its file was edited)
Returns array: of ['name', 'path', 'state', 'ran_at']
Source: framework/core/Migrations.php:75
public function run(?callable $say = null)Runs the pending migrations, in order; stops at the first that fails (the exception names it)
Parameters
-
$say?callable, defaultnull
Returns array: the names that ran
Source: framework/core/Migrations.php:95
public function make($name, $at = null)Writes a new, empty migration: application/migrations/<YYYYMMDDHHMMSS>_<name>.sql
Parameters
$name-
$at, defaultnull
Returns string: its path
Source: framework/core/Migrations.php:125
public static function statements($sql)The statements of a SQL script: split on ; outside quotes ('...', "...", ...) and comments (--, #, /* */),
comments removed, empty statements dropped
Parameters
$sql
Source: framework/core/Migrations.php:147
namespace Caligrafy;
class Validator extends \GUMPSource: framework/core/Validator.php:29
Class that validates inputs
MESSAGES = array('exists' => 'There is no such {param}', 'unique' => 'This {param} is already used')
->__construct()Validator::registerRules()Validator::exists()Validator::unique()Validator::normalize()->validate()->get_errors_array()->check()
public function __construct(string $lang = 'en')No doc comment.
Parameters
-
$langstring, default'en'
Source: framework/core/Validator.php:36
public static function registerRules()Registers the rules exists and unique with GUMP, once. A rule of the same name that the app added first is kept.
Source: framework/core/Validator.php:45
public static function exists(array $params, $value)Whether a value is in table.column (the rule exists)
Parameters
-
$paramsarray $value
Source: framework/core/Validator.php:71
public static function unique(array $params, $value, array $input = array())Whether a value is not yet in table.column (the rule unique), ignoring the row whose column $params[1] equals the input $params[2]
Parameters
-
$paramsarray $value-
$inputarray, defaultarray()
Source: framework/core/Validator.php:81
public static function normalize($rules)The rules as GUMP reads them: unique's extra arguments joined with ; (GUMP keeps one , only) and current_year replaced by the year of today
Parameters
-
$rulesstring|array: 'required|max_numeric,current_year' (or GUMP's array form, kept as it is)
Source: framework/core/Validator.php:101
public function validate(array $input, array $ruleset)No doc comment.
Parameters
-
$inputarray -
$rulesetarray
Source: framework/core/Validator.php:122
public function get_errors_array()The errors by field; exists and unique say what is missing or taken: "There is no such author", "This email is already used" (GUMP::set_error_message() or the per-field messages replace them)
Source: framework/core/Validator.php:131
public function check($data, $rules = array(), $filters = array())No doc comment.
Parameters
$data-
$rules, defaultarray() -
$filters, defaultarray()
Source: framework/core/Validator.php:172
namespace Caligrafy;
class CacheSource: framework/core/Cache.php:25
Class Cache (2.18.0)
$rates = Cache::remember('exchange-rates', 600, fn () => $this->fetchRates()); // at most once every 10 minutes
Cache::put('report:2026-11', $rows, 3600); Cache::get('report:2026-11', []); Cache::forget('report:2026-11');
CACHE_STORE in .env: database (the default with DB_ACTIVATE=true: the caligrafy_cache table, which the deploy step and php caligrafer.php platform install create, shared by the web server, the queue, scheduled jobs and every server), file (the default without a database: a private folder of the temporary directory, of one server and one system user, so the command line and the web server each have their own) or off (nothing is kept, remember() always runs its function). Values are stored as JSON: strings, numbers, booleans, null and arrays (an object comes back as an array). $seconds null keeps a value until it is forgotten or flushed. php caligrafer.php cache clear empties the store.
TABLE = 'caligrafy_cache'STORES = array('file', 'database', 'off')
Cache::store()Cache::get()Cache::has()Cache::put()Cache::forever()Cache::remember()Cache::forget()Cache::flush()Cache::clearMemory()
public static function store()The store in use: file, database or off
Source: framework/core/Cache.php:36
public static function get($key, $default = null)No doc comment.
Parameters
$key-
$default, defaultnull
Source: framework/core/Cache.php:70
public static function has($key)No doc comment.
Parameters
$key
Source: framework/core/Cache.php:76
public static function put($key, $value, $seconds = null)Keeps $value for $seconds (null: until forgotten)
Parameters
$key$value-
$seconds, defaultnull
Source: framework/core/Cache.php:84
public static function forever($key, $value)Keeps $value forever (until forgotten or flushed)
Parameters
$key$value
Source: framework/core/Cache.php:123
public static function remember($key, $seconds, callable $make)The cached value, or the result of $make, kept for $seconds
Parameters
$key$seconds-
$makecallable
Source: framework/core/Cache.php:131
public static function forget($key)No doc comment.
Parameters
$key
Source: framework/core/Cache.php:142
public static function flush()Empties the store
Returns int|null: how many values were removed (null when unknown)
Source: framework/core/Cache.php:159
public static function clearMemory()Forgets this request's copies (tests, a long worker)
Source: framework/core/Cache.php:179
namespace Caligrafy;
class LazySource: framework/core/Model.php:705
#[Caligrafy\Lazy] on a relation method of a model (2.26.0): it may load lazily, without [ERROR 2004] or a warning
No public methods.
namespace Caligrafy;
class LazyLoadingException extends \LogicExceptionSource: framework/core/Model.php:697
Thrown in development when a relation loads lazily on one of several models a query read ([ERROR 2004], 2.26.0)
No public methods.
Caligrafy: Describe it. Approve it. Ship it. Your idea turned into a complete app: every feature built once, for web pages, Vue apps, a REST API and AI agents, and online.
Why Caligrafy: the benefits, the measurements, and what it is not yet
-
Quickstart with Claude: describe it, approve it, ship it
or the Quickstart: the same three steps by hand, in 5 minutes
- How Caligrafy works: the ideas in 5 minutes
- Your first capability: build a feature, page included
-
Capabilities in depth
-
#[Capability]: every option - Scheduled jobs: capabilities on a timer
- Notifications: web push and email
- Background jobs: capabilities run later
- Migrations: database changes, in order
- The cache
-
Testing your app
- Dependency injection
- Validation rules
-
Web pages
- Views and page components
- Design styles: another look, one setting
- Declarative routes: every request, in one line
-
Route::page·Route::form·Route::auth·Route::webhook·Route::download·Route::redirect·Route::action·Route::snap· capability routes - How to export a list as CSV
- Controllers: moving one to a declared route · how to, step by step
- Forms and helpers
-
Vue apps
-
Mobile and tablet
-
REST API
-
AI agents
-
Snap Cards and the assistant
- Payments: Stripe and crypto
- Face detection and face login
- OpenAI: chat and images · Assistants
- Open models: Llama, Mistral...
- Chatbots with Watson
- Machine learning in the browser
- Metadata and social cards · search and analytics
-
Putting it online: the production image, the database at every start
-
API reference: every class and method
-
Routing ·
Route·AuthRoutes· pages ·Controller· capabilities -
Data ·
Model·Query· sign-in · jobs ·Notify· payments · AI -
Interfaces · Snap ·
Snap\Cards·Snap\Conversation· testing · tooling · helper functions
-
Routing ·
-
Caligrafer: every command
- Project · build · data · agents · jobs and tests · maintenance · deploy
- Installation, configuration and Caligrafer
- Routing · Request · Controllers · Views
- Vue: flow of information · routes · validations
- Security and upgrading
- Release notes: 2.26 · 2.25 · 2.24 · 2.23 · 2.22 · 2.21 · 2.20 · 2.19 · 2.18 · 2.17 · 2.16 · 2.15 · 2.14 · 2.13 · 2.12 · 2.11 · 2.10 · 2.9 · 2.8 · 2.7 · 2.6 · 2.5 · 2.4 · 2.3 · 2.1 · October 2026 · changelog
- Testing Caligrafy (contributors)