Configuration
in package
The Configuration class retrieves configuration variables from an .ini file.
It requires the path to the configuration file. As for security, keeping the configuration file out of the web root is the first step. Making it read-only and restricting access may make it more secure. The .ini files have a trivial syntax so they are easy to edit and understand. Also it is the syntax of PHP configuration files.
[application]
name=foo
[template]
name=bar
[sqlite]
database=/path/to/file.sqlite
And then:
$c = new \netico\Bones\Configuration();
$name = $c->getValue('application', 'name');
print $name;
Tags
Table of Contents
- __construct() : void
- This code works if you set the CONFIG constant.
- getValue() : string
- This method gets a configuration option.
Methods
__construct()
This code works if you set the CONFIG constant.
public
__construct() : void
Return values
void —getValue()
This method gets a configuration option.
public
getValue(string $section, string $name) : string
Parameters
- $section : string
-
Section in INI file (for example: '[section]').
- $name : string
-
Key in file INI (for example: 'key=').
Return values
string —Value (for example: '=value').