Repository navigation
API Helpers
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.
The global functions of framework/helpers, loaded for every request and command.
generateKey()generateToken()encryptDecrypt()isSessionExpired()saveInSession()clearFromSession()scripts()design_stylesheet()copyright()keywords()metadata()session()caligrafySessionNeeded()caligrafySessionReady()caligrafySessionMustSave()caligrafySessionStart()caligrafySessionSnapshot()caligrafySessionShutdown()view()api()findKey()recursive_filter()loadConstantFromArray()terminateSession()getGlobalInformation()isAllowedUpload()uploadFile()deleteFile()isJson()sanitize()request()connect()import()parsePath()currentRoute()currentBind()startWith()endWith()sanitizePath()associate()bindRouteToVar()parseRoute()_require_all()singularize()methodField()csrf()errors()old()flash()authorize()authorized()unauthorize()user()guard()logout()imageCanva()load_script()redirect()getRelativeTime()rearrange()httpFile()httpRequest()now()sendMail()arraySort()
function generateKey($size = 32)No doc comment.
Parameters
-
$size, default32
Source: framework/helpers/corehelpers.php:26
function generateToken($size = 12)No doc comment.
Parameters
-
$size, default12
Source: framework/helpers/corehelpers.php:31
function encryptDecrypt($action, $data, $key = APP_KEY)Encryption and Decryption methods used for key identification of entities
Parameters
-
$actionstring: to specify whether it is an ecryption or decryption $data-
$key, defaultAPP_KEY
Returns string: of the encrypted or decrypted field
Source: framework/helpers/corehelpers.php:43
function isSessionExpired($time = SESSION_EXPIRATION_TIME)Checks if a session expired and if it is the session is terminated
Parameters
-
$timeint, defaultSESSION_EXPIRATION_TIME: passes a time argument to override the default session_expiration_time if needed
Source: framework/helpers/corehelpers.php:77
function saveInSession($input_data, $session_variable)Saves forms in a session array
Parameters
-
$input_dataarray: of all variables saved in form -
$session_variablestring: identifies the session array where data should be saved
Source: framework/helpers/corehelpers.php:94
function clearFromSession($session_variable)Clears data from a specific session variable
Parameters
-
$session_variablestring: identifies the session array where data has been saved
Source: framework/helpers/corehelpers.php:110
function scripts($key, $value = null)Gets/Sets script from session by key name
Parameters
-
$keystring: defines the keyname to look for in the session variables -
$value, defaultnull
Source: framework/helpers/corehelpers.php:127
function design_stylesheet()URL of the override stylesheet of the design style selected in .env (DESIGN_STYLE), loaded after the Caligrafy stylesheets; '' for Caligrafy's own look (empty setting, unknown style or stylesheet not written yet)
Source: framework/helpers/corehelpers.php:139
function copyright($value = null)Gets the copyright signature from session
Parameters
-
$value, defaultnull
Source: framework/helpers/corehelpers.php:149
function keywords($value = null)Gets/Sets the keywords
Parameters
-
$value, defaultnull
Source: framework/helpers/corehelpers.php:162
function metadata($pairs = array())Gets/Sets a metadata variable by key
Parameters
-
$pairs, defaultarray()
Source: framework/helpers/corehelpers.php:175
function session($key, $value = null)Gets/Sets a session variable by key
Parameters
$key-
$value, defaultnull
Source: framework/helpers/corehelpers.php:190
function caligrafySessionNeeded($key, $value, $ready)Whether session($key, $value) needs the session started (2.19.0): reading the CSRF token always does (it is handed to a page or a client), a write does once the request's settings ran ($ready, caligrafySessionSnapshot()). The settings (coresettings.php, config.php) write scripts, metadata, keywords... on every request: they stay in memory.
Parameters
$key$value$ready
Source: framework/helpers/corehelpers.php:207
function caligrafySessionReady()Whether the request's settings ran (caligrafySessionSnapshot() was called)
Source: framework/helpers/corehelpers.php:218
function caligrafySessionMustSave($snapshot, array $session, $output)Whether a request that came without a session cookie must save its session when it ends (2.19.0): it changed $_SESSION after the snapshot, or its output carries the CSRF token (a form posts it back)
Parameters
$snapshot-
$sessionarray $output
Source: framework/helpers/corehelpers.php:227
function caligrafySessionStart()Starts the session of a request that came without a session cookie (2.19.0): the values this request already put in $_SESSION are kept. True when the session is active.
Source: framework/helpers/corehelpers.php:240
function caligrafySessionSnapshot()What the session holds once the settings ran (config.php sets metadata, keywords...): a request that changes it afterwards, or whose page carries the CSRF token, gets its session saved (caligrafySessionShutdown)
Source: framework/helpers/corehelpers.php:261
function caligrafySessionShutdown()No doc comment.
Source: framework/helpers/corehelpers.php:271
function view($viewName, $viewData = array())Generic view function that instantiates a View class
Parameters
$viewName-
$viewData, defaultarray()
Source: framework/helpers/corehelpers.php:288
function api($viewData = array())Generic view function that instantiates a View class
Parameters
-
$viewData, defaultarray()
Source: framework/helpers/corehelpers.php:298
function findKey($array, $keySearch)Looks for a key in a multidimensional array
Parameters
-
$arrayarray: define the array to be searched -
$keySearchstring: defines the key to be searched
Returns boolean: if at least one instance is found
Source: framework/helpers/corehelpers.php:312
function recursive_filter(&$array, $allowed)Filters the result depending on package chosen
Parameters
-
$arrayint: defines the array to be filtered -
$allowedarray: defines what the package allows
Returns array: the filtered results
Source: framework/helpers/corehelpers.php:337
function loadConstantFromArray($array)Define constants from 2D array
Parameters
-
$arrayarray: defines the array to turn into constant definition
Returns boolean: if action was executed
Source: framework/helpers/corehelpers.php:359
function terminateSession($url)Terminates a session
Parameters
-
$url: to redirect the user upon session termination
Source: framework/helpers/corehelpers.php:378
function getGlobalInformation($superGlobal = 'session')Function that gets all the super global variables needed for a page to function
Parameters
-
$superGlobalstring, default'session': determines which super variable to fetch information from
Returns array: $result returns an array of all the fetched information desired
Source: framework/helpers/corehelpers.php:396
function isAllowedUpload($filename, $allowedExtensions = null)Checks if a file name has an extension that can safely be uploaded
Parameters
-
$filenamestring: the original file name -
$allowedExtensionsarray, defaultnull: the allowed extensions. Defaults to DEFAULT_UPLOAD_EXTENSIONS
Returns boolean: true if the extension is allowed
Source: framework/helpers/corehelpers.php:438
function uploadFile($picture, $allowedExtensions = null)Uploads a file from a form into the server
Parameters
-
$picturearray: defines the file attributes array (an entry of $_FILES) -
$allowedExtensionsarray, defaultnull: the allowed extensions. Defaults to DEFAULT_UPLOAD_EXTENSIONS
Returns string: the resulting public URL of the uploaded file, or '' if the file was refused or could not be moved
Source: framework/helpers/corehelpers.php:455
function deleteFile($url)Deletes a file given its public path
Parameters
-
$urlstring: of the image public url
Returns boolean: of the result
Source: framework/helpers/corehelpers.php:491
function isJson($string)Checks if a string is a json
Parameters
-
$stringstring: defines the string to be checked
Returns boolean: true if it is a json
Source: framework/helpers/corehelpers.php:511
function sanitize($string)Sanitizes a string from html tags
Parameters
-
$stringstring: defines the string to be sanitized
Returns string: the sanitized screen
Source: framework/helpers/corehelpers.php:526
function request()Accessor to the request information
Returns Request: the request object information
Source: framework/helpers/corehelpers.php:539
function connect()Accessor connects a controller to the model
Returns Model: with connection to database established
Source: framework/helpers/corehelpers.php:552
function import($filename)Accessor to require more librairies and helpers classes and files
Parameters
$filename
Source: framework/helpers/corehelpers.php:564
function parsePath($path)No doc comment.
Parameters
$path
Source: framework/helpers/corehelpers.php:577
function currentRoute()Accessor to the route information
Returns String: the route information
Source: framework/helpers/corehelpers.php:591
function currentBind()Accessor to the list of variables bound to the route
Returns Array: bound variables from the route
Source: framework/helpers/corehelpers.php:602
function startWith($haystack, $needle)Checks if strings starts with a character and removes it
Parameters
$haystack$needle
Returns String: with the character removed
Source: framework/helpers/corehelpers.php:613
function endWith($haystack, $needle)Checks if strings ends with a character and removes it
Parameters
$haystack$needle
Returns String: with the character removed
Source: framework/helpers/corehelpers.php:624
function sanitizePath($path)Sanitizes the path by getting rid of beginning and ending slashes
Parameters
$path
Returns String: the new path without the slashes
Source: framework/helpers/corehelpers.php:636
function associate($controller, $modelname, $table)No doc comment.
Parameters
$controller$modelname$table
Source: framework/helpers/corehelpers.php:643
function bindRouteToVar($route, $uri, $pattern = ROUTE_ARG_PATTERN)No doc comment.
Parameters
$route$uri-
$pattern, defaultROUTE_ARG_PATTERN
Source: framework/helpers/corehelpers.php:648
function parseRoute($path, $pattern = ROUTE_ARG_PATTERN)Parses a path
Parameters
$path-
$pattern, defaultROUTE_ARG_PATTERN
Returns parsed: information
Source: framework/helpers/corehelpers.php:672
function _require_all($path, $depth = 0)load all files in user-created directories and subdirectories
Parameters
$path-
$depth, default0
Source: framework/helpers/corehelpers.php:689
function singularize($word)Singularizes regular plurals
Parameters
$word
Source: framework/helpers/corehelpers.php:712
function methodField($method)Injects a hidden html input to change the method
Parameters
$method
Source: framework/helpers/corehelpers.php:722
function csrf()Injects a csrf field into the form
Source: framework/helpers/corehelpers.php:732
function errors($field = null)The field errors a Route::form() sent back with the previous request (2.19.0): all of them, or one field's message (null when it has none). In a view: if errors('title') / p.cq-field-error= errors('title')
Parameters
-
$field, defaultnull
Source: framework/helpers/corehelpers.php:741
function old($field, $default = '')What a field held when a Route::form() sent it back (2.19.0), else $default: input(name='title', value=old('title')) Passwords and other secrets are never kept.
Parameters
$field-
$default, default''
Source: framework/helpers/corehelpers.php:751
function flash($key, $value = null)A message of the previous request (2.19.0): flash('success') after a Route::form() 'flash', flash('error') after invalid input; with a value, keeps a message for the next request
Parameters
$key-
$value, defaultnull
Source: framework/helpers/corehelpers.php:761
function authorize($user)Method that authorizes a logged in user to perform actions
Parameters
$user
Source: framework/helpers/corehelpers.php:776
function authorized()Method that checks if a session user is allowed to perform actions
Source: framework/helpers/corehelpers.php:786
function unauthorize()Method used upon logout to unauthorize a user in session from performing actions
Source: framework/helpers/corehelpers.php:796
function user()Method that retrieves the user currently logged in
Source: framework/helpers/corehelpers.php:806
function guard(
$permissionAttribute,
$acceptedPermission,
$loginUrl = '/login',
$notAuthorized = '/notAuthorized'
)Method that checks if the user in session has permissions to access
Parameters
$permissionAttribute$acceptedPermission-
$loginUrl, default'/login' -
$notAuthorized, default'/notAuthorized'
Returns boolean: of whether or not the user is valid and allowed to perform actions
Source: framework/helpers/corehelpers.php:815
function logout($redirectUrl = '/')Method that logs the user out
Parameters
-
$redirectUrl, default'/'
Source: framework/helpers/corehelpers.php:823
function imageCanva()Method that instantiates the Claviska Simple Image library that manipulate pictures
Source: framework/helpers/corehelpers.php:834
function load_script($params)Loads a script into the UI
Parameters
-
$paramsarray: inputs needed to generate the script
Returns string: HTML or TXT fully formatted
Source: framework/helpers/corehelpers.php:854
function redirect($url)Reroutes to another url
Parameters
$url
Source: framework/helpers/corehelpers.php:874
function getRelativeTime($datetime, $depth = 1)Get RelativeTime
Parameters
$datetime-
$depth, default1
Source: framework/helpers/corehelpers.php:891
function rearrange($arr)Rearrange multi-dimensional array onto key array. Used to rearrange File inputs
Parameters
$arr
Source: framework/helpers/corehelpers.php:947
function httpFile($url, $filepath, $headers, $username = null, $password = null, $purpose = 'assistants')cUrl post file function
Parameters
$url$filepath$headers-
$username, defaultnull -
$password, defaultnull -
$purpose, default'assistants'
Source: framework/helpers/corehelpers.php:959
function httpRequest($url, $method, $data, $headers, $username = null, $password = null)cUrl request function
Parameters
$url$method$data$headers-
$username, defaultnull -
$password, defaultnull
Source: framework/helpers/corehelpers.php:998
function now()now() returns the current timestamp in a mySQL format
Source: framework/helpers/corehelpers.php:1038
function sendMail($recipients, $emailContent, $from)sendMail() sends an email using the configuration in the .env file
Parameters
-
$recipientsarray: : array('email' => 'recipient_email', 'name' => 'recipent_name) $emailContent$from
Source: framework/helpers/corehelpers.php:1049
function arraySort($array, $attribute, $sort = SORT_DESC)arraySort() sorts a multimdimensional array by a column
Parameters
-
$arrayarray: defines the array to sort -
$attributestring: defines the column to sort by -
$sortstring, defaultSORT_DESC: defines the sorting direction: SORT_ASC, SORT_DESC
Returns array: sorted array
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)