Minimal mode

From Cloudrexx Development Wiki
Jump to: navigation, search

This article is about the minimal mode.


The API documentation is located at

Accessing API in standalone PHP script

To access the API in a standalone PHP script, all you have to do is to initialize a minimal instance of Contrexx. This is done with the following code:

require_once '/<path to Contrexx installation>/core/Core/init.php';
$cx = init('minimal');

From that point on, you'll have full access to the whole Contrexx framework from within your standalone PHP script.

Reading session data

Once you have established a connection to Contrexx (as explained above) you can also access the Contrexx session data of the requesting user (as anything else from the Contrexx framework). To do so, simply initialize the session as explained in section Initialization of article Session handling. Then you can access the session data through the superglobal $_SESSION.

Checking for authenticated user

You can also check if the requester is currently signed in to the Contrexx website and access its user data as explained in the section Authentifizierter Besucher of article User / Group. Note: Manually initializing the Contrexx session is not required, as checking for an authenticated user will automatically initialize the session.

Example code:

require_once '/<path to Contrexx installation>/core/Core/init.php';
$cx = init('minimal');

if (\FWUser::getFWUserObject()->objUser->login()) {
    // Der aktuelle Benutzer ist authentifiziert
    // Auf die Daten des aktuell authentifizierten Benutzers kann über das
    // Objekt \FWUser::getFWUserObject()->objUser zugegriffen werden.
    print "Sie sind angemeldet als ".\FWUser::getFWUserObject()->objUser->getUsername();
} else {
    // Der aktuelle Benutzer ist nicht authentifiziert
    print "Sie sind nicht angemeldet!";