Helpers

The framework provides some basic helper functions in order to ease your workflow.

//Returns the full path to your projects root directory
function base_path()

//Returns the full path to your app directory
function app_path()

//Returns the full path to your resources directory
function resource_path()

//Returns the full URL to your projects folder
function base_url()

//Return the full URL to the given path
function url($path)

//Returns the full URL to your app directory
function app_url()

//Returns the full URL to your resources directory
function resource_url()

//Return the full URL to the specified asset
function asset($path)

//Returns the current CSRF token of your session
function csrf_token()

//Adds a new template command. First param
//is the name of the command, second param is a callback of type: function (string
//$code, array $args):string. $code contains the code line with the template. $args
//contains the arguments of the template command if any (must be wrapped in
//brackets like valid PHP code). Return value is a string with the code that the
//template command line shall be replaced with.
function template_command($ident, $callback)

//Short way of spawning a ViewHandler instance.
function view($layout, array $yields, $vars = array())

//Short way of returning JSON content
function json(array $content)

//Short way of returning XML content
function xml(array $content, $root = 'data')

//Short way of returning CSV content
function csv(array $content, array $header = null)

//Short way of returning plain text content
function text($content)

//Short way of redirecting to an URL
function redirect($to)

//Return from POST route to the related GET route
function back()

//Short way of letting the client download a resource
function download($resource)

//Shortname function to call env_get()
function env($item, $fallback = null)

If you want to use localized Carbon then you can use the Carbon helper to automatically use the current locale. Therefore just create an instance from Carbon (global namespace) instead of Carbon\Carbon.

© 2020 by Daniel Brendel - all rights reserved