CRX Framework PHP - Documentation.

Last update : 02/2020

Architecture of CRX php framework 

CRX Framework work for scripting on service mode or on webmode, 

on webmode it can provide librairies and also tools for CRX Cms witch a CMS with MVC organisation. 

CMS or SCRIPT have the same design: 

html /     ( HTML folder is the application folder content )

[app-php] / [module] / 

[app-js] / [module] / 

So each folder represent a module, for example in web mode :   forum, mail, directory,

Exemple for from CLI service mode : dxClusterServer ( witch work with socket/thread/shared memory ) or dxClusterMailAlert witch is an alerting daemon. 

Of course in same application it's possible to mix server mode and web mode ( server mode = script mode here ). 

Inside each module you have these folders : 

conf_files   ( containt module xml conf file ) 







On parent level , we have : 

conf /  (configuration folder contain VHOST configuration and registry of crx application ). 

logs /  ( can contain APACHE log but also CRX Framework log )


Example of script application : 


	'appli_web_uri'			=>	$APPWEBURI,
	'appli_name'			=>	$APPNAME,	
	'appli_webmaster_email'	=>  $APPWEBMASTERMAIL,

	'appli_reg_path'		=>	$APPFSPATH.'/conf/', 								//registry folder 
	'appli_path'			=>	$APPFSPATH.'/html/',								//_APPLI_MAIN_PATH_	
    'appli_path_root'		=>	$APPFSPATH,
	'appli_secret_key'		=>	$APPSECKEY,											//_APPLI_SEC_KEY_
	'error_handling'		=>  array(
		'PhpDisplay'		=>	$error
	'server_os'				=>	'LINUX',			//_SERVER_TYPE_
	'current_path'			=>	$APPFSPATH.'/html',	//_SERVER_EXEC_PATH_
	'framework_debug_mode'			=>  'nothing',	//view/nothing/log
	'framework_error_mode'			=>  'nothing',	//view/nothing/log
	'framework_path'				=>	$FMPATH.'/',
	'framework_conf'				=>  array(
		'time_zone_set'							=>	'Europe/Paris',		
		'framework_debug_console'				=>  NULL,		//view/nothing/log
		'app_main_ds'							=>  'mysql',
		'load_user_module'						=>	1,
		'load_user_authentification_module'		=>	1,
		'available_languages'					=>	array('fr','en'),
		'default_language'						=>	'fr', //can be fr,en  OR auto (detect from user browser_info)
		'default_loaded_module'						=>	'dxClusterWeb',
		'process_options_for_module_to_load'	=>  array('action'	=>	'CRON__updateUserProfileNumberOfSpots')


As you can see this instance will call the module "dxClusterWeb" and the class method "CRON__doSpotArchiving", arguments to the script can  be transmit via process_options_for_module_to_load  array. 


Example of web call : 

This example call CRX-CMS from the index.php file. 

Here we call the cms module dxClusterWeb when user is login-in. 




	'appli_web_uri'			=>	$APPWEBURI,//_WEBSITE_URL_
	'appli_name'			=>	$APPNAME,		//_APPLI_NAME_
	'appli_webmaster_email'	=>  $APPWEBMASTERMAIL,		//_APPLI_WEBMASTER_MAIL_

	'appli_reg_path'		=>	$APPFSPATH.'/conf/', 	//registry folder 
	'appli_path'			=>	$APPFSPATH.'/html/',	//_APPLI_MAIN_PATH_
	'appli_path_root'		=>	$APPFSPATH,				//path outside html/www folder using for registry and log(s). 
	'appli_secret_key'		=>	$APPSECKEY,											//_APPLI_SEC_KEY_

	'error_handling'		=>  array(
		'PhpDisplay'		=>	$error

	'server_os'			=>	'LINUX',				//_SERVER_TYPE_
	'current_path'		=>	getcwd(),				//_SERVER_EXEC_PATH_

	'framework_debug_mode'			=>  $fmer,				//view/nothing/log
	'framework_error_mode'			=>  $fmer,				//view/nothing/log

	'framework_path'				=>	$FMPATH.'/',
	'framework_conf'				=>  array(

		'caching_xml_to_memcached'			=>	1, // 0 disable // default 1 => use for module configuration XML.
		'caching_xml_to_php'				=>	1, // 0 disable // default 1 => use for modules global conf/list.

		'caching_ini_to_php'				=>	1, // default 1 => use for languages ini files.
		'caching_ini_to_user_session'			=>  1, // default 1 => use for languages ini files.

		'time_zone_set'					=>	'Europe/Paris',

		//'framework_debug_console'				=>  '',		//view/nothing/log

		//'app_main_ds'							=>  'mysql', // default 'll be mysql !

		'load_user_module'				=>	1,
		'load_user_authentification_module'		=>	1,

		'set_user_authentification_method'		=>	'webUserAuthentification',

		'load_stats_visitor_module'			=>	0,
		'load_common_module'				=>	1,

		'display_modules_output'			=>	1,

		'available_languages'				=>	array('fr','en','it','es'),
		'default_language'					=>	'fr', //can be fr,en  OR auto (detect from user browser_info)

		'if_access_to_unknow_module'		=>	'load_default_module',// or view_404, load_default_module,print_error, do_nothing, die.
		'define_404_page'					=>	getcwd().'/404.php',
		'common_module_name'				=>	'common',

		'default_loaded_module'				=>	'index',
		'on_user_login_in_module'			=>	'dxClusterWeb',//dxClusterWeb

		'maintenance_mode'				=>	0,

		'loadCommondModuleConfiguration'		=>	1,

		'enforceUriSecurityMode'			=> 	$urlmode, //b64id (require in AJAX mode), normal

		'saveUriEncodingIntoMemCache'			=>	0, //TODO 1

		'cachingDataSource'				=>	'memcached-localhost'




Module env : 

Inside a module, you can use pre defined method : 

$this->showVars();     // display framework constant defined. 

$this->loadIco();        // load HTML Ico picture. 

$this->_currentModuleConfiguration   // current module XML configuration :     /html/app-php/[MODULE_NAME]/conf_files/configuration_module.xml

All values defined into array 'framework_conf' ( see boot method of bootScript  or  bootweb ), are accessibles :

via  crxFramework::getFrameworkConfigurationValue method : 

Example : 


Will return sha256 for exemple. 


Module configuration format : 

Configuration module is defined via XML configuration file like this : 

<?xml version="1.0" encoding="ISO-8859-1"?>
		<mail_admin_send_test_ob>CRXHAM - testingmail</mail_admin_send_test_ob>

As you can see, you must use the following tag:    module, conf   and you can put what ever you want inside conf xml tag. 

=> To apply new  configuration for module, you must  login/logout and before restart your memcached service. 

Debug something into a module : 

Here we debug $cmd var into a debug log file ( witch is located into log folder on root ) :

//to debug $cmd content :

Of course, we can also debug to output via this method :

into the script loader ( boot script / web script ), we configure the display with this directive set to "view" :

//default is nothing

'framework_debug_mode'			=>  'view',				//view/nothing/log

Now into the controller module, we can use this function "debugAndContinue", this function take the message and a boolean :

Here is it's a mail alert service process witch run in background :

	function handle__startDxclusterMailAlertProcess(){
		debugAndContinue('[INFO] '.mktime()."  Now Starting mailler alert processus.",DEBUG_MAIL_PROCESS);
			debugAndContinue('[INFO] '.mktime()."  Check if there is new spot to send.",DEBUG_MAIL_PROCESS);	

Framework env :

All constant php are define here :

[FRAMEWORK PATH] / loader / constant.php

You can ajust some value, if you need advanced debug for example.

define('DEBUG_WEBSERVICE_CRX_LAYER',0);//See crxFrameworkWebserviceCrx
define('ENABLE_LOG_DEBUG',0);//See crxFrameworkWebserviceCrx
define('_DEBUG_LOG_FILE_','/tmp/debug_php.log');//Set debug path

To view framework content you can use :  


Using database classe 

CRX Framework, purpose a powerfull object to SQL mapper, and various method to generate SQL and create schema from object class properties : 

$this->_dataAccess = crxDataSource::getDs('mysql_local');    

First inside object, you must define the table schema you want, example : 

    var $_userDonationTableShema = array(

Example 1 , return data with a filter ( similar to SELECT request ) : 


$this->_dataAccess    -> ExecSql();

return $this->_dataAccess -> returnLineAsso();

Example 2, insert data : 

            $this->_dataAccess    ->    defineTableShema($this->_userDonationTableShema);
            $this->_dataAccess    ->    formatSqlQuery($updatedata,$this->_table_users_donation,'INSERT');
            $this->_dataAccess    ->    execSql();   

Example 3, update data : 

            $this->_dataAccess    ->    defineTableShema($this->_userDonationTableShema);
            $this->_dataAccess    ->    formatSqlQuery($updatedata,$this->_table_users_donation,'UPDATE',array('donation_id'=>$donation_id));
            $this->_dataAccess    ->    execSql();    

If error, you can extract it via this command :    ( execSql return FALSE ) 

$this->_dataAccess    ->    getExecSqlError();     

Developping module, use ini file languages

To disable cache, during developpement use :