Ocs-server/Gfx4/Global and local configuration: Difference between revisions
Created page with "GFX use a class to load config every time from a bunch of files. You can also create your config and find them placed under EConfig. Most of the gfx-related configurations ar..." |
No edit summary |
||
Line 5: | Line 5: | ||
If you edit your /config/database.conf.php like this: | If you edit your /config/database.conf.php like this: | ||
<syntaxhighlight lang="php"> | |||
<?php die(); ?> | |||
name|test | |||
host|localhost | |||
user|root | |||
password|asd | |||
</syntaxhighlight> | |||
You will automatically find them mapped into an associative array: | You will automatically find them mapped into an associative array: | ||
<syntaxhighlight lang="php"> | |||
EConfig::$data["database"]["name"]; | |||
</syntaxhighlight> | |||
Note that '''"database"''' is the name of the config file without extensions and '''"name"''' is the variable name. | Note that '''"database"''' is the name of the config file without extensions and '''"name"''' is the variable name. | ||
Line 22: | Line 26: | ||
-------------- | -------------- | ||
'''Filename: /config/myname.conf.php''' | '''Filename: /config/myname.conf.php''' | ||
<syntaxhighlight lang="php"> | |||
<?php die(); ?> | |||
info|Claudio|Desideri|kde | |||
</syntaxhighlight> | |||
If you access '''EConfig::$data["myname"]["info"];''' you get an array containing all the values. | If you access '''EConfig::$data["myname"]["info"];''' you get an array containing all the values. | ||
You can iterate on it using: | You can iterate on it using: | ||
<syntaxhighlight lang="php"> | |||
foreach(EConfig::$data["myname"]["info"] as $item){ | |||
echo $item; | |||
} | |||
</syntaxhighlight> | |||
This will print: | This will print: | ||
Line 37: | Line 45: | ||
And via code that will be accessible using: | And via code that will be accessible using: | ||
<syntaxhighlight lang="php"> | |||
$info = EConfig::$data["myname"]["info"]; | |||
$info[0]; | |||
$info[1]; | |||
$info[2]; | |||
</syntaxhighlight> | |||
--------- | |||
===Generic.conf.php=== | |||
Each website (or subsite) must have a ''generic.conf.php'' file inside the ''config'' folder. These are the properties that can be setted through generic: | |||
* '''render''': can be "yes" or "no" | |||
* '''protectheaders''': can be "yes" or "no" | |||
* '''database''': can be "yes" or "no" | |||
* '''rewrite''': can be "yes" or "no" | |||
* '''users''': can be "yes" or "no" | |||
* '''mvc''': can be "yes" or "no" | |||
* '''errormode''': can be "yes" or "no" | |||
* '''enabled''': can be "normal", "formatted", "file" or "suppressed" | |||
* '''password''': password of your choice | |||
Example of a ''generic.conf.php'' file: | |||
<syntaxhighlight lang="php"> | |||
<?php die(); ?> | |||
render|yes | |||
protectheaders|yes | |||
database|yes | |||
rewrite|yes | |||
users|no | |||
mvc|yes | |||
errormode|normal | |||
enabled|protected | |||
password|esempio | |||
</syntaxhighlight> |
Revision as of 11:33, 28 July 2015
GFX use a class to load config every time from a bunch of files. You can also create your config and find them placed under EConfig.
Most of the gfx-related configurations are on the file /config/generic.conf.php. If you create the folder "config" on a subfolder of gfx, that will behave as a subsite on its own, with its MVC, rewriting and libs.
If you edit your /config/database.conf.php like this:
<?php die(); ?>
name|test
host|localhost
user|root
password|asd
You will automatically find them mapped into an associative array:
EConfig::$data["database"]["name"];
Note that "database" is the name of the config file without extensions and "name" is the variable name.
Also note that PHP code in config files will just be ignored, so it's good practice to put a die(); on the first line so no one will be able to see your inner configuration.
You can also use multi value properties like this:
Filename: /config/myname.conf.php
<?php die(); ?>
info|Claudio|Desideri|kde
If you access EConfig::$data["myname"]["info"]; you get an array containing all the values. You can iterate on it using:
foreach(EConfig::$data["myname"]["info"] as $item){
echo $item;
}
This will print:
Claudio Desideri kde
And via code that will be accessible using:
$info = EConfig::$data["myname"]["info"];
$info[0];
$info[1];
$info[2];
Generic.conf.php
Each website (or subsite) must have a generic.conf.php file inside the config folder. These are the properties that can be setted through generic:
- render: can be "yes" or "no"
- protectheaders: can be "yes" or "no"
- database: can be "yes" or "no"
- rewrite: can be "yes" or "no"
- users: can be "yes" or "no"
- mvc: can be "yes" or "no"
- errormode: can be "yes" or "no"
- enabled: can be "normal", "formatted", "file" or "suppressed"
- password: password of your choice
Example of a generic.conf.php file:
<?php die(); ?>
render|yes
protectheaders|yes
database|yes
rewrite|yes
users|no
mvc|yes
errormode|normal
enabled|protected
password|esempio