Application Helpers
- Introduction
- HTTP management helper
- Database
- Security
- Event management
- Storage system
- Application helper
- Strings
- Other
- Usage
- Is something missing?
Introductionβ
Helpers are shortcut functions loaded into the application that let you quickly perform certain actions. Here is the list of helpers that exist in the BowPHP application. Below are the helpers available in the application.
HTTP management helperβ
app, config, response, request, json, download, set_status_code, view, session, cookie, create_csrf_token, csrf_token, csrf_field, method_field, generate_token_csrf, verify_csrf, csrf_time_is_expired, sanitize, secure, set_header, get_header, redirect, send, curl, url, flash, validator, route, old, client_locale, redirect_back
Databaseβ
db, table, get_last_insert_id, db_select, db_select_one, db_insert, db_delete, db_update, db_statement, db_transaction, db_transaction_started, db_rollback, pdo, set_pdo, db_commit, db_seed
Securityβ
encrypt, decrypt, app_hash, bow_hash
Event managementβ
listen_event, listen_event_once, listen_transmisson_event, listen_transmisson_event, emitter, emit_event
Storage systemβ
ftp, s3, config, mount, file_system, cache
Application helperβ
app_env, app_assets, app_abort, app_abort_if, app_mode, auth, logger
Stringsβ
str_slug, str_is_mail, str_is_domain, str_is_slug, str_is_alpha, str_is_lower, str_is_upper, str_is_alpha_num, str_shuffle_words, str_wordify, str_plurial, str_camel, str_snake, str_contains, str_capitalize, str_random, str_force_in_utf8, e, str_fix_utf8
Emailβ
Otherβ
debug, sep, collect, trans, t, __
Usageβ
appβ
This helper gives you access to the BowPHP container.
app("mail");
configβ
Gives you access to the BowPHP configuration.
config("mail")
responseβ
Gives you access to an instance of \Bow\Http\Response::class. It must be used inside a controller. You can find more information about the available methods here
return response($content = "hello papac", $code = 200);
requestβ
Gives you access to an instance of \Bow\Http\Request::class. It must be used inside a controller. You can find more information about the available methods here
$name = request()->get("name");
jsonβ
Lets you use the json method of \Bow\Http\Response::class. It must be used inside a controller.
return json(["name" => "papac"], $code = 200);
// {"name": "papac"}
downloadβ
During a request, lets you download a file. It is bound to the \Bow\Http\Response::class class. It must be used inside a controller.
$file = "/path/to/file.png";
$filename = "photo.png";
return download($file, $filename);
set_status_codeβ
Lets you change the HTTP status code of the response. It is bound to the \Bow\Http\Response::class class. It must be used inside a controller.
set_status_code(404);
viewβ
Lets you compile a view in BowPHP.
return view("view.name", ["name" => "papac"], $code = 200);
sessionβ
Lets you manipulate the session interface in BowPHP.
session($value, $default = null)
- If no argument is passed, it retrieves the session instance.
- If
defaultis provided and the value does not exist, it will be returned as the fallback value. - If
$valueis an associative array, it will add this information to the session as key-value pairs.
cookieβ
cookie("name", "papac");
// papac
create_csrf_tokenβ
create_csrf_token();
// papac
csrf_tokenβ
$token = csrf_token();
// papac
csrf_fieldβ
$field = csrf_field();
// <input type="hidden" name="token" value="token_value" />
method_fieldβ
$method = method_field("DELETE")
// <input type="hidden" name="_method" value="DELETE" />
generate_token_csrfβ
generate_token_csrf();
// papac
verify_csrfβ
verify_csrf($token);
// bool
csrf_time_is_expiredβ
csrf_time_is_expired();
// bool
sanitizeβ
$name = sanitize("papa'c")
// papac
secureβ
$name = request()->get("name");
// papac
set_headerβ
set_header("X-Token-API", $token);
get_headerβ
$token = get_header("X-Token-API");
// papac
redirectβ
return redirect();
// papac
redirect_backβ
return redirect_back();
sendβ
return send("hello papac");
// hello papac
curlβ
curl("https://github.com/bowphp");
urlβ
$name = request()->get("name");
// papac
flashβ
$name = request()->get("name");
// papac
validatorβ
$name = request()->get("name");
// papac
routeβ
$name = request()->get("name");
// papac
oldβ
$name = request()->get("name");
// papac
client_localeβ
$name = request()->get("name");
// papac
https://github.com/bowphp/framework/blob/4.0/src/Support/helper.php
Is something missing?
If you run into problems with the documentation or have suggestions to improve the documentation or the project in general, please open an issue for us, or send a tweet mentioning the Twitter account @bowframework or directly on github.