PHP code example of oasys / config
1. Go to this page and download the library: Download oasys/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/ */
oasys / config example snippets
declare(strict_types=1);
return [
'name' => 'myApp',
'origin' => 'http://localhost/',
'dev_mode' => true
];
declare(strict_types=1);
use Oasys\Config\ArrayConfig;
$config = new ArrayConfig(
__DIR__ . '/config/app.php'
);
$value = $config->get('app.name');
"myApp"
declare(strict_types=1);
return [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'myapp_dev',
'username' => 'johndoe',
'password' => 'secret',
'encoding' => [
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci'
]
];
declare(strict_types=1);
use Oasys\Config\ArrayConfig;
$config = new ArrayConfig(
__DIR__ . '/config/app.php',
__DIR__ . '/config/db.php'
);
$config->get('db.driver');
"mysql"
$config->get('db.encoding.charset');
"utf8mb4"
$config->get('db.port', 3306);
3306
$config->has('db.password');
true
$config->has('db.port');
false
$config->all();
[
'app' => [
'name' => 'myApp',
'origin' => 'http://localhost/',
'dev_mode' => true
],
'db' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'myapp_dev',
'username' => 'johndoe',
'password' => 'secret',
'encoding' => [
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci'
]
]
]