-
Notifications
You must be signed in to change notification settings - Fork 1
Helpers
kaythinks edited this page Apr 10, 2020
·
10 revisions
The Helpers class has many functions that can be called independently.
debug($value);
The debug function can be called by passing a value as an argument e.g debug($objectValue);
csrf_token()
The csrf_token() is called in forms to prevent CSRF attacks, it accepts no argument and it returns a token which is usually a random set of strings. It can be called like this e.g csrf_token()
enable_cors()
This function is used to enable CORS(Cross origin resource sharing), it should be called before the actual code is written in a method e.g
/**
* This method is for accessing an API endpoint
*
* @return JSON Response
*/
public function getResponse() {
try {
enable_cors();
http_response_code(200);
$data = [
"success" => "Successfully Touched this API Endpoint",
"random_quote" => Goodthoughts::generateThought()
];
echo json_encode($data);
} catch (\Exception $e) {
Logger::error($e);
echo json_encode($e->getMessage());
}
}
Made with love in Naija