PHP code example of comphp / config-yaml

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

    

comphp / config-yaml example snippets




use CommonPHP\Drivers\Config\YAML\YamlConfigurationDriver;

$driver = new YamlConfigurationDriver();

$config = [
    'app' => 'demo',
    'debug' => true,
    'database' => [
        'host' => 'localhost',
    ],
];

$yaml = $driver->encode($config);
$decoded = $driver->decode($yaml);

$driver->write(__DIR__ . '/config.yaml', $config);
$fromFile = $driver->read(__DIR__ . '/config.yaml');