Tiniest PHP framework
Just run composer install [package_name]
After that all these functions should be available in every PHP file (via composer's autoloader)
Handles a CORS request
function handle_cors($domainCheck = NULL, $extra = [])
Returns domain of the app
function get_domain()
Returns the HTTP method
function get_http_method($allowed = ['get', 'post', 'options'])
Returns the HTTP method
function check_http_method(...$allowed)
Handles a file upload
function handle_upload($names = NULL, $destDir = NULL, $allowedExt = NULL)
Process PHP json request
function handle_json_request()
Gets value from config file
function config($name, $default)
Return app's base dir
function app_dir($path = NULL, $check_exists = TRUE)
Creates a URL for current app
function url($url, $params = [])
Creates a pre-authenticated url
function auth_url($url, $user_id, $activity = 'link_click', $data = [])
Check if it is a ajax request
function is_ajax_request()
Redirect to login page with error
function login_redir($message = '')
Aborts a request with 403 error code
function abort($message = '', $code = 403)
Redirect to another url
function redirect($location, $code = 302, $message = NULL)
Returns a request param
@return string|array
function request($name = NULL, $default = NULL)
Adds a route for router
function add_route(string $path, $action, $method = '', $auth = FALSE)
Simplest PHP router
function router()
Returns the name of the JWT COOKIE
function jwt_cookie_name()
Get logged in user
function user($key = '', $default = NULL)
Logged in user's id
function user_id()
Checks if the user is logged-in (returns user_id) otherwise aborts
function check_login()
Sets a global cookie
function site_set_cookie($name, $value, $expires = 0)
Log in a user by starting session
function user_login($user, $expires = 86400)
Logs out existing user
function user_logout()
All publicly accessible user info
function user_info_public($user = NULL)
Checks if the user is authenticated in guest mode and if so returns the user_id (false otherwise)
function guest_id()
Handles setting up environment for handling http requests
function bootstrap($env)