Quick links: Content - sections - sub sections
EN FR

A jRequest object for each type of request

A jRequest object handles the processing of the input data in order to make it easily available to the framework and especially to the actions. It allows, among other things, to determine the actions to execute.

There are several types of jRequest objects, processing different input data. Indeed, we don't retrieve the input data for a HTML page (in the url (get) or encoded in the body of the HTTP request (post) ), the same way as we would do for a SOAP request (data in the body of the HTTP request in XML).

For each jRequest object, corresponds one or more authorized output format, then one or more authorized jResponse object.

The available jRequest object are :

  • classic: for the classical requests whose response type is not important (html, text, redirection ..)
  • soap: for SOAP request, when you want implement some SOAP services. The response should be in SOAP format.
  • xmlrpc: for the XMLRPC requests. The response must be in XMLRPC
  • jsonrpc: for the JSONRPC requests. The response must be in jSONRPC

Other requests types are possible of course.

Entry points

An entry point is a script which manage a part or all your application actions. Only entry points should be web accessible and therefore should lie in www/ directory of your application. It should exist an entry point for each type of request that you want to use. As a result, each entry point should also have its specific configuration file.

An entry point create a jCoordinator object, a jRequest object (to parse all request parameters) and indicates which configuration file to use. For the classic entry point (so index.php), it looks like this:


// application initialisation file
require_once ('../../testapp/application.init.php');

// configuration file
$config_file = 'index/config.ini.php';

// jCoordinator object
$jelix = new jCoordinator($config_file);

// jRequest object
require_once (JELIX_LIB_CORE_PATH.'request/jClassicRequest.class.php');
$request = new jClassicRequest();

// action processing
$jelix->process($request);

API

During the action processing, the request object is accessible throw the request property of the jCoordinator object. This object is accessible throw a global variable $gJCoord.


// To retrieve a request parameter
$myfooValue = $GLOBALS['gJCoord']->request->getParam('foo');

But in a controller, you have some method to do the same things shortly:


 $myfooValue = $this->param('foo');

Some other properties are available :

type to know the request type.
url_script_path the path to the script in the url
url_script_name the script name (so the name of the entry point)
url_path_info The pathinfo part of the url
params request parameters

Some methodes:

  • getIp(): to retrieve the IP of the client
  • isAjax(): to know if the request is an ajax request or not.