Config

How configuration files work


The configuration files are located in the /config folder. Let's see an example of configuration file:

/config/app.php
return [
    "A" => "some value A",
    "B" => "some value B",
    "C" => 1,
    "D" => true,
    "E" => **any type of value**
    ...
];

The values are accessed using the config() function, passing the keys as arguments according to dot notation. The second and final argument (optional) represents the default value if the searched key does not exist.

Configurations in custom paths

In addition to the conventional location used by Monti, you can place configuration files anywhere you like. To access the values, use the static method \App\System\Config::get(). The first argument is the absolute path to the configuration file, the second is the key of the value being searched, and the third is the default value.

\App\System\Config::get("/absolute/path/to/config_file.php", "some.key", "optional default value");

Additional information

Passing the name of the configuration file to config() will return the entire array.

config("app");

Passing an empty string ("") as the key, or no key at all, will return the entire array of the configuration file.

//no key
config("config_file");
\App\System\Config::get("/absolute/path/to/config_file.php");

//empty string
config("config_file", "");
\App\System\Config::get("/absolute/path/to/config_file.php", "");