Configure Nephtali

From Nephtali Documentation

Jump to: navigation, search

Nephtali uses one lone configuration file, nconfig.php.

nconfig.php

The nconfig.php contains a function call that accepts 4 arguments:

Mode
The current mode of the Nephtali site. Options include 'dev', 'test', 'prod'.
Dev
The array of values available for the dev environment.
Test
The array of values available for the test environment.
Prod
The array of values available for the prod environment.

Example

An example of an nconfig.php file is below:

n\config\save(
    $mode = 'dev',
    $dev = array(
        'sql_action_dsn'        => 'mysql:host=localhost;dbname=DBNAME',
        'sql_action_username'   => 'DEV_USERNAME',
        'sql_action_password'   => 'PASSWORD',
        'sql_source_dsn'        => 'mysql:host=localhost;dbname=DBNAME',
        'sql_source_username'   => 'USERNAME',
        'sql_source_password'   => 'PASSWORD',
        'encryption_key'        => 'ENCRYPTION_KEY',
        'encryption_salt'       => 'ENCRYPTION_SALT',
        'special_value'         => 'SPECIAL_VALUE'
    ),
    $test = array(
        'sql_action_dsn'        => 'mysql:host=localhost;dbname=DBNAME',
        'sql_action_username'   => 'TEST_USERNAME',
        'sql_action_password'   => 'PASSWORD',
        'sql_source_dsn'        => 'mysql:host=localhost;dbname=DBNAME',
        'sql_source_username'   => 'USERNAME',
        'sql_source_password'   => 'PASSWORD',
        'encryption_key'        => 'ENCRYPTION_KEY',
        'encryption_salt'       => 'ENCRYPTION_SALT'
    ),
    $prod = array(
        'sql_action_dsn'        => 'mysql:host=localhost;dbname=DBNAME',
        'sql_action_username'   => 'PROD_USERNAME',
        'sql_action_password'   => 'PASSWORD',
        'sql_source_dsn'        => 'mysql:host=localhost;dbname=DBNAME',
        'sql_source_username'   => 'USERNAME',
        'sql_source_password'   => 'PASSWORD',
        'encryption_key'        => 'ENCRYPTION_KEY',
        'encryption_salt'       => 'ENCRYPTION_SALT',
        'error_page'            => 'error.php'
    )
);

Accessing Values

Accessing values in nconfig.php is done via calls to the function n\config\get($name), which returns the value according the the mode of the application.

For example, if the mode was set to 'test', calls to n\config\get('sql_action_username') would return 'TEST_USERNAME' in the example code above.

Two key points regarding nconfig.php values:

  1. Values set in nconfig.php are immutable, so you can't change a value once it's been set.
  2. You can add any key and value you like. In the example code above, the 'dev' mode array includes a 'special_value' that could be retrieved just as any other value.
Personal tools