Helpers

Helpers are just global functions that are availble through modules and are easy to use in views.

The Quantum framework comes with several usuful predefined helper functions.

  • qt_instance() - Returns Quantum controller instance
  • view() - Returns rendered view
  • get_current_module() - Returns current module
  • current_controller() - Returns current controller
  • current_action() - Returns current action
  • session() - Facade to SessionManager (will be covered in sessions section)
  • redirect($url, $code = NULL) - Redirects to given the `$url`
  • get_referrer() - Returns the referrer
  • current_url() - Returns the current url
  • base_dir() - Returns the path of base directory
  • public_dir() - Returns the path of public directory
  • uploads_dir() - Returns the path of public directory
  • base_url() - Returns the base URL
  • get_config($key) - Returns the the config value by the given `$key`
  • slugify($text) - Normalize and pretify the string for urls and paths
  • get_user_ip() - Returns the remote IP
  • out($var, $die = false) - Outputs the dump of the given `$var`
  • env($var, $default = false) - Returns the environment variable by given `$var`
  • csrf_token() - Returns the CSRF token (will be covered in CSRF section)
  • _t() - Outputs the translated text
  • t() - Returns the translated text

You are free to define your own custom functions in function.php under base helpers directory and the framework will load them.

It's possible to load helpers from other places with load($path = BASE_DIR) method of Helpers class by passing the path of the helpers directory.

<< Prev Next >>