PHP code example of yasd / config
1. Go to this page and download the library: Download yasd/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/ */
yasd / config example snippets
use Nette\Schema\Expect;
use YaSD\Config\AbstractConfig;
use stdClass;
class MyConfig extends AbstractConfig
{
public const MYKEY = 'mykey';
public function getMyValue(): int
{
return $this->get(
self::MYKEY,
Expect::int(),
);
}
public function getMysql(): stdClass
{
return $this->get(
'mysql',
Expect::structure([
'host' => Expect::string()->
$config = new MyConfig(__DIR__ . '/test.config.php');
$ret = $config->reload()->getMyValue();
var_dump($ret);
$ret = $config->getMysql();
var_dump($ret);