Function Helpers
Introduction
Public directory
Generate random characters
Redirect
with_msg
alert_msg
Dump and Die
DB()
abort
bcrypt
checkHash
error_page_code
gate_denies
sanitizeString
route
view
appversion
csrf
basepath
vendorpath
Introduction
Sprnva has a function helpers. It's just a normal functions that you can call in your controllers or in views.
You will find the function helpers at config/function.helpers.php
. Then this is how you declare a helper function.
You can now access and use these helper function in your controllers and views.
Public directory
This is how to access public directory with a helper function.
Generate random characters
Sprnva has a helper function that can generate random characters good for (ex: product_code, project_code etc.)
. Accepts a parameter $length
which means how many characters you wanted to print.
Redirect
Redirect use to redirect to another page with a message.
with_msg
Register an alert message
alert_msg
Display the message as alert with color
Dump and Die
Sometime we need to dump something to know the value of that particular $variable
so dd()
helper comes to help.
DB()
For simplicity and more readable code we added a helper function to get the instance of our database connection.
abort
redirect to an error page then die(). This will show the error page base on the error code.
bcrypt
This will hash the given value and return a hash string
checkHash
Check the given plain value against a hash and return a bool
error_page_code
List of all error codes.
gate_denies
check if user role has permission
sanitizeString
Sanitize strings trim, stripslashes, htmlspecialchars
route
Set a route to redirect
view
Require a view.php page
appversion
Show the current version of the framework
csrf
This will add a hidden input with csrf token
basepath
Get the app root path
vendorpath
Get the app vendor path
Last updated