Skip to content
nebukadnezzar edited this page Apr 7, 2013 · 11 revisions

Create a route with respond($method, $route, $callback) or respond($route, $callback) where callback is function ($request, $response)

$request->
    header($key)                        //Gets a request header
    cookie($key)                        //Gets a cookie from the request
    session($key)                       //Gets a session variable
    param($key, $default = null)        //Gets a request parameter (get, post, named)
    params()                            //Return all parameters
    params($mask = null)                //Return all parameters that match the mask array - extract() friendly
    validate($param, $err_msg = null)   //Starts a validator chain
    method()                            //Gets the request method
    method($method)                     //Checks if the request method is $method, i.e. method('post') => true
    isSecure($required = false)         //https? Redirect if $required is true and the request is not secure
    id()                                //Gets a unique ID for the request
    ip()                                //Get the request IP
    userAgent()                         //Get the request user agent
    uri()                               //Get the request URI
    <property>                          //Gets a request parameter

$response->
    header($key, $value = null)                     //Sets a response header
    cookie($key, $value = null, $expiry = null)     //Sets a cookie
    cookie($key, null)                              //Removes a cookie
    flash($msg, $type = 'info', $params = array()   //Sets a flash message
    file($file, $filename = null)                   //Send a file
    json($object, $callback = null)                 //Send an object as JSON(p)
    markdown($str, $args, ...)                      //Return a string formatted with markdown
    code($code)                                     //Sends an HTTP response code
    redirect($url, $code = 302)                     //Redirect to the specified URL
    refresh()                                       //Redirect to the current URL
    back()                                          //Redirect to the referer
    render($view, $data = array())                  //Renders a view or partial (NOTE: in the scope of $response)
    layout($layout)                                 //Sets the view layout
    yield()                                         //Call inside the layout to render the view content
    onError($callback)                              //$callback takes ($response, $msg, $err_type = null)
    set($key, $value = null)                        //Set a view property or helper
    set($arr)
    escape($str)                                    //Escapes a string
    query($key, $value = null)                      //Modify the current query string
    query($arr)
    param($param, $default = null)                  //Gets an escaped request parameter
    flashes($type = null)                           //Retrieves and clears all flashes of $type (or all flash messages)
    flush()                                         //Flush all open output buffers
    discard()                                       //Discard all open output buffers
    buffer()                                        //Return the contents of the output buffer as a string
    dump($obj)                                      //Dump an object
    chunk($str = null)                              //Enable response chunking (see the wiki)
    <callback>($arg1, ...)                          //Calls a user-defined helper
    <property>                                      //Gets a user-defined property

$validator->
    notNull()                           //The string must not be null
    isLen($length)                      //The string must be the exact length
    isLen($min, $max)                   //The string must be between $min and $max length (inclusive)
    isInt()                             //Checks for a valid integer
    isFloat()                           //Checks for a valid float/decimal
    isEmail()                           //Checks for a valid email
    isUrl()                             //Checks for a valid URL
    isIp()                              //Checks for a valid IP
    isAlpha()                           //Checks for a-z (case insensitive)
    isAlnum()                           //Checks for alphanumeric characters
    contains($needle)                   //Checks if the string contains $needle
    isChars($chars)                     //Validates against a character list
    isRegex($pattern, $modifiers = '')  //Validates against a regular expression
    notRegex($pattern, $modifiers ='')
    is<Validator>()                     //Validate against a custom validator
    not<Validator>()                    //The validator can't match
    <Validator>()                       //Alias for is<Validator>()
Clone this wiki locally