extends
BrObjectHelper to work with request.
There is one global request object (singleton) accessible via br()->request()
. You can still create own request obejct if needed by $request = new BrRequest();
Method/property | Description |
---|---|
If you are using global config, please prepend below methods with br()->request() | |
referer() | |
isSelfReferer() | |
isAt(url) | |
isAtBaseUrl() | |
path() | |
clientIP() | |
url() | |
relativeUrl() | |
baseUrl() | |
build(array) | |
frameworkUrl() | |
setFrameworkUrl(path) | |
domain() | |
serverAddr() | |
isLocalHost() | |
host() | |
scriptName() | |
ifModifidSince() | |
method() | |
isMethod(method) | |
isGET() | |
isPOST() | |
isPUT() | |
isDELETE() | |
isRedirect() | |
isTemporaryRedirect() | |
isPermanentRedirect() | |
userAgent() | |
isMobile() | |
get(name, defaultValue) | |
post(name, defaultValue) | |
put(name, defaultValue) | |
cookie(name, defaultValue) | |
param(name, defaultValue) | |
isFilesUploaded() | |
file(name) | |
fileTmp(name) | |
fileName(name) | |
fileSize(name) | |
fileError(name) | |
isFileUploaded(name) | |
moveUploadedFile(name, destinationFolder) | |
continueRoute() | |
routeComplete() | |
route(method, path, callback) | |
route(path, callback) | |
routeGET(path, callback) | |
routePOST(path, callback) | |
routePUT(path, callback) | |
routeDELETE(path, callback) | |
routeIndex(callback) | |
routeDefault() | |
check(condition, callback) |
Again, if you are working with global config object you can use br()->config(name, defaultValue)
instead of br()->config()->get(name, defaultValue)
for simplicity.
br() ->request() ->route('/index.html', function() { // display homepage }) ->route('/order.html?client=([0-9]+)', function($matches) { // display order of client $matches[1] }) ->routeGET('/pay.html', function() { // display payment page }) ->routePOST('/pay.html', function() { // handle POST to pay.html }) ->routeIndex(function() { // handle request to root url of your site }) ->routeDefault() ;
Once some of the routes processed - other ones will be skipped. Simple, isn't it?