PHP code example of andrewdyer / settings

1. Go to this page and download the library: Download andrewdyer/settings library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

andrewdyer / settings example snippets


$settings = new Settings([
    'app_name' => 'My Application',
    'database' => [
        'host' => 'localhost',
        'port' => 5432,
        'credentials' => [
            'username' => 'admin',
            'password' => 'secret',
        ],
    ],
]);

$all = $settings->all();

$appName = $settings->get('app_name'); // 'My Application'

$host = $settings->get('database.host'); // 'localhost'

$username = $settings->get('database.credentials.username'); // 'admin'

$database = $settings->get('database');

$settings->has('app_name'); // true

$settings->has('database.credentials.password'); // true

$settings = new Settings([
    'database.host' => 'literal',
]);

$settings->get('database.host'); // 'literal'

$settings = new Settings([
    'database' => [
        'host' => 'nested',
    ],
]);

$settings->get('database.host'); // 'nested'