-
Notifications
You must be signed in to change notification settings - Fork 34
ROUTING
The Scavix WebFramework contains a built in routing mechanism that best work with apaches mod_rewrite, but will also do it's job without. The basic concept is, that you define a controller class that contains methods, which are 'addressable' from the browser. You may use the buildQuery function to create URLs that are qualified for your installation. Sample:
buildQuery('home','index',['message'=>'Hi']);
This will result in:
http://your.domain/index.php?wdf_route=home/index&message=Hi
or with mod_rewrite enabled:
http://your.domain/home/index?message=Hi
If you open such an URL in your browser, the Home
controller will be created an it's method Index
will be invoked.
class Home extends HtmlPage
{
/**
* @attribute[RequestParam('message','string',false)]
*/
function Index($message)
{
$this->content("Message: $message");
}
}
Notice the DocComment? This is a feature called Attribution and it is used to easily parse arguments from the request to method arguments. WDF supports a set of attributes used for different purposes.