All 45 public functions. Full descriptions and examples are in the project's AGENTS.md. Functions starting with ink_ are kernel internals; pages don't call them.
json(mixed $data, int $code = 200): never | send JSON and stop |
redirect(string $to, int $code = 302): never | local redirect; external targets are refused |
abort(int $code, string $message = ''): never | error page (HTML or JSON) |
url(string $path = '/'): string | absolute URL (config base_url or the request Host) |
cache_public(int $seconds): void | let browsers and CDNs cache |
store_upload(string $field, array $types = [...], int $maxBytes = 5_000_000): ?string | save an upload, return its URL |
upload_error(): ?string | why the last upload failed |
asset(string $path): string | /assets/… with a version |
db(): PDO | the PDO connection (lazy) |
q(string $sql, array $params = []): PDOStatement | run SQL |
one(string $sql, array $params = []): ?array | one row or null |
all(string $sql, array $params = []): array | all rows |
val(string $sql, array $params = []): mixed | first column of the first row |
tx(callable $fn): mixed | transaction |
validate(array $data, array $rules): array | [$clean, $errors] |
session(): void | start the session |
flash(string $key, ?string $msg = null): ?string | one-time message |
csrf_token(): string | CSRF token |
csrf_field(): string | hidden form field |
csrf_check(): void | check the token, else 403 |
csrf_exempt(string $reason): void | declare a page intentionally without CSRF |
login(int|string $id): void | log in (rotates the session id) |
logout(): void | log out |
user(): int|string|null | current user id |
require_login(string $loginPath = '/login', bool $hidden = false): int|string | require login; hidden → 404 |
rate_limit(string $key, int $max, int $windowSeconds): void | rate limit, else 429 |