Application configuration - ApinePHP/legacy-framework GitHub Wiki
APIne Framework requires a configuration file allowing to save configuration entries for the Framework to work properly. It is actively used by core components requiring specific information from the developer. The file must be named config.ini and located at the root of the project's directory. This files must be accessible with reading and writing permissions enabled.
Developer may also use additional configuration files for their modules in they want or simply use the default one. If they want to use additional files, they will need to manually invoke the config file using the Configuration Utility described in the Utility section.
Configuration files SHOULD use the INI file format with sections to store data.
Usage
// Get instance of the application config (Method 1)
$config = Apine\Application\Application::get_config();
// Get instance of the application config (Method 2)
$config2 = Apine\Application\Config::get_instance();
// Open a new instance of the application config
$config3 = new Apine\Core\Config();
// Get the value of an option
$value = $config->get(‘database’, ‘dbname’);
// Set the value of an option
$config->set(‘database’, ‘dbname’, $value);
Available configurations per sections
Application
The application section is named [application] and is used by the default views. It may contain these options:
author: Project author name;description: Project description;title: Project name.
Database
The database section is named [database] and MUST contain these options:
type: Type of PDO connection. Usuallymysql,pgsql,sqlite,sqlsrvorodcb;host: Hostname of the server. It can be either a domain name, an IP address or a local host name;dbname: Database name. Name of the database to connect to;charset: Connection encoding. We strongly recommendutf8;username: Database user;password: Database user's password.
Localization
The localization section is named [localization] and refers to the translation module. It MUST contain these options:
locale_default: A ISO 8601 locale code representing the default locale the translation module must use. A json of the same name must exist in the translation folder`;locale_cookie:yesorno. Should the framework try to look for a cookie during locale detection;locale_detection:yesorno. Indicates if locale detection must be active;timezone_default: Valid PHP time zone. Please refer to the PHP documentation for a complete list of available timezones. It is used as a fallback when the framework cannot find a timezone for the remote address.
Mailing
The section represents the primary email server, is named [mail], and is optionnal. It is used by the mailing module. It may contain these options:
host: Hostname of the server. It can be either a domain name, an IP address or a local hostname;port: Port to use to connect to the mailing server;protocol: Transport protocol to use when connecting to the server. It is advisable to usesslortls;smtp_auth:0or1. Defined if authentication is required to connection to the SMTP server;smtp_username: SMTP username;smtp_password: SMTP password;sender_name: Optional Name to send the message as. It can be overridden during execution;sender_address: Optional Email address to send the message as. It can be overridden during execution.
Runtime
The runtime section is named [runtime] and may contain these options:
encryption_key: A custom encryption key for the encryption component. This option is generated and managed by the application. DO NOT create, modify or delete this option;default_layout: Default view layout for the project;session_lifespan: Lifespan of a web session in seconds.7200(24 hours) by default;token_lifespan: Lifespan of a API token in seconds.600(10 minutes) by default;user_class: See Extended Users;webroot: Path to the APIne application from the webroot.