Skip to content

API Controller

Dory Azar edited this page Nov 15, 2026 · 2 revisions

Caligrafy\Controller

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.

Part of Controllers and views.

namespace Caligrafy;

class Controller extends \stdClass

Source: framework/core/Controller.php:19

Parent Class that defines the properties and methods of a controller

Methods

->__construct()

public function __construct($modelname = '', $table = null)

No doc comment.

Parameters

  • $modelname, default ''
  • $table, default null

Source: framework/core/Controller.php:28

->__invoke()

public function __invoke($modelname, $table)

No doc comment.

Parameters

  • $modelname
  • $table

Source: framework/core/Controller.php:33

->activatePayment()

public function activatePayment()

Activates a the Stripe Payment module

Source: framework/core/Controller.php:64

->associate()

public function associate($modelname, $table)

Associates a controller with a model optionally with a table in the database

Parameters

  • $modelname
  • $table

Source: framework/core/Controller.php:73

->index()

public function index()

Implied default function that will run when no action has been determined at runtime

Source: framework/core/Controller.php:82

->all()

public function all($args = array())

Basic common CRUD function that fetches all data from the associated table

Parameters

  • $args, default array()

Source: framework/core/Controller.php:88

->find()

public function find($id = null)

Basic common CRUD function that finds a particular record

Parameters

  • $id, default null

Source: framework/core/Controller.php:96

->save()

public function save($inputs, $id = null)

Basic common CRUD function that saves data to the database whether adding a new record or updating an existing one

Parameters

  • $inputs
  • $id, default null

Source: framework/core/Controller.php:104

->delete()

public function delete($id = null)

Basic common CRUD function that deletes a record from the database

Parameters

  • $id, default null

Source: framework/core/Controller.php:114

->search()

public function search($scope = null, $keywords = null)

No doc comment.

Parameters

  • $scope, default null
  • $keywords, default null

Source: framework/core/Controller.php:120

->table()

public function table()

Gets the table that is associated with a model

Source: framework/core/Controller.php:131

->check()

public function check($data, $rules = array(), $filters = array())

Filtering and Validation through a controller

Parameters

  • $data
  • $rules, default array()
  • $filters, default array()

Source: framework/core/Controller.php:139

->validate()

public function validate($data, $rules)

Validation through a controller

Parameters

  • $data
  • $rules

Source: framework/core/Controller.php:147

->filter()

public function filter($data, $filters)

Filtering through a controller

Parameters

  • $data
  • $filters

Source: framework/core/Controller.php:156

->view()

public function view($viewName, $viewData = array())

return a Pug template view with viewData passed to it

Parameters

  • $viewName
  • $viewData, default array()

Source: framework/core/Controller.php:165

->api()

public function api($viewData = array())

return a view consumable by APIs

Parameters

  • $viewData, default array()

Source: framework/core/Controller.php:173

->call()

public function call($name, $input = null)

Calls a capability as the signed-in user (web pages): the same rules as REST and MCP

try { $book = $this->call('create_book'); redirect('/books/' . $book['id']); }
catch (ServiceError $e) { return view('Books/form', ['errors' => $e->fields]); }

Parameters

  • $name string: the capability
  • $input array|null, default null: the inputs (default: the request parameters and the route variables)

Returns mixed: plain data

  • @throws ServiceError

Source: framework/core/Controller.php:187

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.

Start here

Why Caligrafy: the benefits, the measurements, and what it is not yet

  1. Quickstart with Claude: describe it, approve it, ship it

    or the Quickstart: the same three steps by hand, in 5 minutes

  2. How Caligrafy works: the ideas in 5 minutes
  3. Your first capability: build a feature, page included

Capabilities

Experiences

Data and people

  1. Models
  2. Relationships
  3. Queries: filters, paging, related rows
  4. Sign-in, users and tokens

Built-in features

Put it online

Build with AI

Reference

Clone this wiki locally