izartu API

Documentation

Table of Contents

Packages

Application

Classes

Auth
Session-based authentication: login, logout, session state, route guarding and CSRF tokens. All methods are static; `Auth::start()` must run before any output.
Bookmark
A bookmark: a typed record plus its own persistence (Active Record).
Cli
What the command-line scripts in `private/cli/` share: their prompts.
Controller
Route handlers for the front controller (index.php). Each handler deals with one route and returns a `[template, variables]` pair to render, or redirects and exits directly.
Crud
Database access for a table: prepare and run a query, then fetch its rows.
Database
The shared PDO connection, opened on the first query.
DatabaseUnavailable
The database could not be reached.
Debug
Request diagnostics, collected while DEBUG is on: every executed query with its wall time (fed by DebugStatement), reported as a `Server-Timing` header (browser devtools, curl) and as the query panel at the bottom of the page.
DebugStatement
PDOStatement that reports each execution's wall time to Debug. Installed through `PDO::ATTR_STATEMENT_CLASS` when DEBUG is on (see Database), so every query is timed without touching any call site.
Failure
How a failed request is answered: 503 when the database is unreachable or a query fails on a database behind the code, both temporary, and 500 for anything else.
Flash
One-shot session message, shown on the page after a redirect.
Format
Present a timestamp for the view.
Input
Typed access to request input. Superglobals carry no type guarantees (a crafted request can turn any field into an array), so every read narrows to a string here and the rest of the code never touches them raw.
Migration
The database schema's migrations: SQL files applied in order, each recorded in the `migration` table.
Redirect
A redirect: thrown by the code that decides it, and sent as a `Location` header by the front controller.
ShowTag
Supply the tag cloud and the tag index to the view, as data for the template to render.
User
User records: look up accounts for authentication.
Version
What is running, and where its source lives.
View
Render a view template inside the page layout.

Traits

Tag
Tag queries: a bookmark's tags and the tag-cloud data.

Enums

Visibility
Whether a bookmark is visible to everyone on the instance or only its owner.

Constants

BASE  : mixed = \env('BASE', \basePath())
Base URL path of the install ('' at a domain root, '/sub' in a sub-directory).
CLOUD_SIZE  : mixed = \max(1, (int) \env('CLOUD_SIZE', '50'))
Most-used tags shown in the tag cloud.
DB_HOST  : mixed = \env('DB_HOST', 'localhost')
Database host ('localhost' by default).
DB_NAME  : mixed = \env('DB_NAME', 'izartu')
Database name ('izartu' by default).
DB_PASS  : mixed = \env('DB_PASS')
Database password (required, no default).
DB_PORT  : mixed = (int) \env('DB_PORT', '3306')
Database port (3306 by default).
DB_SSL_CA_FILE  : mixed = \env('DB_SSL_CA_FILE')
CA file to verify the server's certificate against (unset by default: the CAs the system trusts).
DB_SSL_ENABLED  : mixed = \filter_var(\env('DB_SSL_ENABLED', '1'), \FILTE...
Encrypt the connection over TCP; a Unix socket, `localhost` included, never is. On by default; `0`/`false`/`off`/`no` turn it off, any other value on.
DB_SSL_VERIFY_CERT  : mixed = \filter_var(\env('DB_SSL_VERIFY_CERT', \DB_SSL_...
Verify the server's certificate, name included. On by default with `DB_SSL_CA_FILE`, off without it; `0`/`false`/`off`/`no` turn it off, any other value on.
DB_USER  : mixed = \env('DB_USER')
Database user (required, no default).
DEBUG  : mixed = \filter_var(\env('DEBUG'), \FILTER_VALIDATE_BOOL)
Debug mode (off by default; `1`/`true`/`on`/`yes` enable it): PHP's errors and the cause of a failed request on the page, the Server-Timing header and the query panel.
PAGE_SIZE  : mixed = \max(1, (int) \env('PAGE_SIZE', '10'))
Bookmarks per page on the feed.
PRIVATE_DIR  : mixed = __DIR__ . '/'
Application bootstrap: fixed paths, class autoloading and configuration.
PUBLIC_DIR  : mixed = \dirname(__DIR__) . '/public/'
TAGS_PAGE_SIZE  : mixed = \max(1, (int) \env('TAGS_PAGE_SIZE', '100'))
Tags per page on the tag index (`/tags`).
TIMEZONE  : mixed = \env('TIMEZONE', \date_default_timezone_get())
Timezone of the dates shown, such as 'Europe/Madrid' (PHP's `date.timezone` by default; UTC when that is unset). A name PHP does not know stops the app.
VERSION  : mixed = \env('VERSION', \Version::running())
The running version, shown in the footer and linked to its source; read from the tree when unset.

Functions

env()  : string
An environment variable as a string, or a default when unset/empty.
basePath()  : string
The base URL path the request came in on: '' at a domain root, '/sub' in a sub-directory install. Off the web there is no request, so the CLI and the test suite get ''.
asset()  : string
A web-root-relative asset path carrying a cache-busting query string.

Constants

BASE

Base URL path of the install ('' at a domain root, '/sub' in a sub-directory).

public mixed BASE = \env('BASE', \basePath())

Detected from the request by default; set it when a reverse proxy serves the app under a path the request does not carry.

CLOUD_SIZE

Most-used tags shown in the tag cloud.

public mixed CLOUD_SIZE = \max(1, (int) \env('CLOUD_SIZE', '50'))

DB_HOST

Database host ('localhost' by default).

public mixed DB_HOST = \env('DB_HOST', 'localhost')

DB_NAME

Database name ('izartu' by default).

public mixed DB_NAME = \env('DB_NAME', 'izartu')

DB_PASS

Database password (required, no default).

public mixed DB_PASS = \env('DB_PASS')

DB_PORT

Database port (3306 by default).

public mixed DB_PORT = (int) \env('DB_PORT', '3306')

DB_SSL_CA_FILE

CA file to verify the server's certificate against (unset by default: the CAs the system trusts).

public mixed DB_SSL_CA_FILE = \env('DB_SSL_CA_FILE')

DB_SSL_ENABLED

Encrypt the connection over TCP; a Unix socket, `localhost` included, never is. On by default; `0`/`false`/`off`/`no` turn it off, any other value on.

public mixed DB_SSL_ENABLED = \filter_var(\env('DB_SSL_ENABLED', '1'), \FILTER_VALIDATE_BOOL, \FILTER_NULL_ON_FAILURE) !== \false

DB_SSL_VERIFY_CERT

Verify the server's certificate, name included. On by default with `DB_SSL_CA_FILE`, off without it; `0`/`false`/`off`/`no` turn it off, any other value on.

public mixed DB_SSL_VERIFY_CERT = \filter_var(\env('DB_SSL_VERIFY_CERT', \DB_SSL_CA_FILE === '' ? '0' : '1'), \FILTER_VALIDATE_BOOL, \FILTER_NULL_ON_FAILURE) !== \false

DB_USER

Database user (required, no default).

public mixed DB_USER = \env('DB_USER')

DEBUG

Debug mode (off by default; `1`/`true`/`on`/`yes` enable it): PHP's errors and the cause of a failed request on the page, the Server-Timing header and the query panel.

public mixed DEBUG = \filter_var(\env('DEBUG'), \FILTER_VALIDATE_BOOL)

PAGE_SIZE

Bookmarks per page on the feed.

public mixed PAGE_SIZE = \max(1, (int) \env('PAGE_SIZE', '10'))

PRIVATE_DIR

Application bootstrap: fixed paths, class autoloading and configuration.

public mixed PRIVATE_DIR = __DIR__ . '/'

Every entry point (public/index.php, private/cli/*, the test suite) requires this file; config.php holds the operator-editable settings.

PUBLIC_DIR

public mixed PUBLIC_DIR = \dirname(__DIR__) . '/public/'

TAGS_PAGE_SIZE

Tags per page on the tag index (`/tags`).

public mixed TAGS_PAGE_SIZE = \max(1, (int) \env('TAGS_PAGE_SIZE', '100'))

TIMEZONE

Timezone of the dates shown, such as 'Europe/Madrid' (PHP's `date.timezone` by default; UTC when that is unset). A name PHP does not know stops the app.

public mixed TIMEZONE = \env('TIMEZONE', \date_default_timezone_get())

VERSION

The running version, shown in the footer and linked to its source; read from the tree when unset.

public mixed VERSION = \env('VERSION', \Version::running())

Functions

env()

An environment variable as a string, or a default when unset/empty.

env(string $name[, string $default = '' ]) : string
Parameters
$name : string

The variable name.

$default : string = ''

Value when the variable is unset or empty.

Return values
string

basePath()

The base URL path the request came in on: '' at a domain root, '/sub' in a sub-directory install. Off the web there is no request, so the CLI and the test suite get ''.

basePath() : string
Return values
string

asset()

A web-root-relative asset path carrying a cache-busting query string.

asset(string $path) : string

The file's modification time gives every deployed version its own URL, so a browser never keeps an old copy against new markup. A leading slash is dropped, so the path stays relative for <base href> (sub-directory installs). A missing file, a directory and a path with a .. segment (which may name a file outside the web root) get the plain path.

Parameters
$path : string

Path under the web root, for example 'style/main.css'.

Return values
string —

The relative path, with '?v=' appended when it names a readable file under the web root.

Search results