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 script '''master.inc.php''' that must be called at beginning of every PHP program (scripts or pages).
Content of file must be used by developers by using predefined constants or the object '''$conf''' created by the script '''master.inc.php''' that must be includes at beginning of every PHP program (scripts or pages).
Your code must never open the config file and read it directly. This is not necessarly.


So:
* $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
* $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
Line 58: Line 58:
* $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''' (to be called by every PHP pages) that created on object connexion '''$db''' then variable $dolibarr_main_db_pass is erased.


You development should only need to use constants DOL_DOCUMENT_ROOT (that indicate physical path of directory where permanent or temporary files are stored) and DOL_URL_ROOT (that indicate relative URL that is Dolibarr root).
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)
More information and initialized objects are available after including a call to '''main.inc.php''' in your PHP pages.
* 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