Helpers are functions that help the developer manipulate classes, without having to instantiate them.
Here you will find the helpers that exist in Solital Framework. Some specific helpers are not listed on this page, but you can find them on the next pages of the documentation.
Some helpers can be replaced by methods, as long as you use them inside a Controller.
/**
* @param string $name
* @param mixed $parameters
* @param null|array $getParams
*/
url(?string $name = null, $parameters = null, ?array $getParams)
response()
request()
/**
* @param string|null $index: Parameter index name
* @param string|null $defaultValue: Default return value
* @param array ...$methods: Default methods
*
* @return mixed
*/
input(string $index = null, string $defaultValue = null, ...$methods)
# With method
$this->getRequestParams(string $index = null, string $defaultValue = null, ...$methods)
/**
* @param string $url: the route to which you will be redirected
* @param int|null $code: HTTP code
*/
to_route(string $url, ?int $code = null)
# Or, use a method
$this->redirect(string $url, ?int $code = null)
/**
* @param string $key: key to identify the requisition
* @param int $limit: number of times the request can be made
* @param int $seconds: waiting time until it is possible to make the request again.
*
* @return bool
*/
request_limit(string $key, int $limit = 5, int $seconds = 60)
# With method
$this->requestLimit(string $key, int $limit = 5, int $seconds = 60)
/**
* @param string $key: key to identify the requisition
* @param string $value: value that will be added
*
* @return bool
*/
request_repeat(string $key, string $value)
# With method
$this->requestRepeat(string $key, string $value)
csrf_token()
/**
* @param string $method: GET, POST, PUT or DELETE
*/
spoofing(string $method)
/**
* @param mixed $value: the user's password.
* @param int $cost: which denotes the algorithmic cost that should be used.
*/
pass_hash($value, int $cost = 10)
pass_hash
helper or the PHP Secure Password component/**
* @param mixed $value: the user's password.
* @param string $hash: a hash created by `pass_hash()`.
*/
pass_verify($value, string $hash)
See Wolf Template to use Wolf helpers.
public/assets/_css/
folder./**
* @param string $asset: CSS file name
*/
load_css(string $asset)
minify()->style()
method.load_min_css()
public/assets/_js/
folder./**
* @param string $asset: javascript file name
*/
load_js(string $asset)
minify()->script()
method.load_min_js()
public/assets/_img/
folder./**
* @param string $asset: image file name
*/
load_img(string $asset)
public/assets/
folder./**
* @param string $asset: external file name
*/
load_file(string $asset)
var_dump
./**
* @param mixed $value: to format
*/
pre($value)
cloner
uses Symfony VarCloner
function. See more./**
* @param mixed $var
*/
cloner($var)
true
to return as an array./**
* @param mixed $var
* @param bool $length
*/
dumper($var, bool $length = false)
dump
function.dump($var)
export
uses the Symfony VarExport
function. See more./**
* @param mixed $value
*/
export($value)
/**
* @param mixed $value: to JSON
*/
encodeJSON($value)
true
to convert JSON to an array./**
* @param mixed $value: to JSON
* @param bool $toArray: convert JSON object in array
*/
decodeJSON($value, bool $toArray = false)
/**
* @param mixed ...$messages
*
* @return void
*/
console_log(...$messages)
To get a value from an existing session, leave the $value
parameter empty. To create a new session, inform the session key in the first parameter, and the session value in the second parameter. See more in Session and Cookies.
/**
* @param string $key: index that will identify the session
* @param mixed $value: session value
* @param mixed $defaultValue: array of values (see Session class documentation)
* @param bool $delete: if the value is `true`, the session will be deleted.
* @param bool $take: returns the requested value and removes it from the session.
*
* @return mixed
*/
session(string $key, mixed $value = null, mixed $defaultValue = null, bool $delete = false, bool $take = false)
remove_param()
# With method
$this->removeParamsUrl()
/**
* @param mixed $string: verify if value is JSON
*/
is_json($string)
/**
* @param string $uri
*/
get_url(string $uri = null)
/**
* @param string $path
*
* @return string|null
*/
mb_basename(string $path)
/**
* @param string $glue
* @param array $array
* @param string $symbol
*
* @return string
*/
mapped_implode(string $glue, array $array, string $symbol = '=')
ArrayCollection
class without having to instantiate it./**
* @param mixed $value
*
* @return ArrayCollection
*/
collection(mixed $value = null)
Str
class without having to instantiate it./**
* @param string $string
*
* @return Str
*/
str(string $string)