Configuration file: Difference between revisions

Jump to navigation Jump to search
Line 46: Line 46:


= Usage in coding =
= Usage in coding =
Content of file must be used by developers by using predefined constants or the object '''$conf''' created by the file '''master.inc.php''' or '''main.inc.php''' that must be included at beginning of every PHP program (master.inc.php for scripts or main.inc.php for pages).
Content of file must be used by developers by using predefined loaded constants or the object '''$conf''' created by the code into files '''master.inc.php''' or '''main.inc.php''' (that must be included at beginning of every PHP program: master.inc.php for scripts or main.inc.php for pages).
Your code must never open the config file and read it directly. This is not necessarly.
Your code must never open the config file and read it directly. This is not necessarly.


* $dolibarr_main_document_root is known in code in constant: DOL_DOCUMENT_ROOT
* $dolibarr_main_document_root is known in code in constant: DOL_DOCUMENT_ROOT (that indicate physical path of directory where permanent or temporary files are stored).
* $dolibarr_main_url_root is known in code in constant: DOL_URL_ROOT
* $dolibarr_main_url_root is known in code in constant: DOL_URL_ROOT (that indicate relative URL that is Dolibarr root).
* $dolibarr_main_db_type is known in code on variable $conf->db->type
* $dolibarr_main_db_type is known in code on variable $conf->db->type
* $dolibarr_main_db_host is known in code on variable $conf->db->host
* $dolibarr_main_db_host is known in code on variable $conf->db->host
Line 56: Line 56:
* $dolibarr_main_db_name is known in code on variable $conf->db->name
* $dolibarr_main_db_name is known in code on variable $conf->db->name
* $dolibarr_main_db_user is known in code on variable $conf->db->login
* $dolibarr_main_db_user is known in code on variable $conf->db->login
* $dolibarr_main_db_pass is not known by code. It is read by script '''master.inc.php''' (to be called by every PHP pages) that created on object connexion '''$db''' then variable $dolibarr_main_db_pass is erased.
* $dolibarr_main_db_pass is not known by code. It is read by script '''master.inc.php''' that created on object connexion '''$db''' then variable $dolibarr_main_db_pass is erased.
 
However, your development should never have to use this variables but only should use instead following global variable or constants:
* DOL_DOCUMENT_ROOT (that indicate physical path of directory where permanent or temporary files are stored)
* DOL_URL_ROOT (that indicate relative URL that is Dolibarr root).
* $db
* $conf
* $user
* $langs


See tutorial on page [[Module development|Module development]] or [[Script development]] for more information.
See tutorial on page [[Module development|Module development]] or [[Script development]] for more information.

Navigation menu