Skip to content

Global Helpers

controller()

controller() — returns any

Available in: controller, model, test, migrator, migration, tabledefinition Category: Miscellaneous Functions

The controller() function creates and returns a controller object with a custom name and optional parameters. It is primarily used for testing, but can also be used in code to instantiate a controller programmatically. Unlike the deprecated routing controller() function, this helper does not define routes—it creates controller instances.

NameTypeRequiredDefaultDescription
namestringyesName of the controller to create.
paramsstructno[runtime expression]The params struct (combination of form and URL variables).
testController = controller("users", params);