PHP code example of lawondyss / config

1. Go to this page and download the library: Download lawondyss/config 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/ */

    

lawondyss / config example snippets


class DbConfig extend Lawondyss\Config
{
  public string $driver;
  public string $host;
  public string $database;
  public string $username;
  public string $password;
  public string $charset;
}

$dbConfig = DbConfig::fromArray([
  'driver' => 'mysqli',
  'host' => 'localhost',
  'database' => 'example',
  'username' => 'root',
  'password' => 'root',
  'charset' => 'utf8'
]);

$charset = $dbConfig->charset;
$dbConfig->charset = 'latin1';

$pass = $dbConfig['password']; 
$dbConfig['password'] = '*****';

class DbConfig extend Lawondyss\Config
{
  public string $driver = 'mysqli';
  public string $host = 'localhost';
  public string $database;
  public string $username;
  public string $password;
  public string $charset = 'utf8';
}

$defaultConfig = new DbConfig;

$lipsumDbConfig = $defaultConfig->withOptions([
  'database' => 'lipsum',
  'username' => 'lorem',
  'password' => 'ipsum',
]);

$dibi = new Dibi\Connection($lipsumDbConfig->toArray());