PHP code example of rkulik / config

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

    

rkulik / config example snippets

 php

// config.php

return [
    'hello' => 'world',
];
 php

// index.php

Rkulik\Config\ConfigFactory();

$config = $configFactory->make('config.php');

echo $config->get('hello'); // world
 php

// config.php

return [
    'hello' => 'world',
];
 php

// CustomParser.php

use Rkulik\Config\FileParser\FileParserInterface;

class CustomParser implements FileParserInterface
{
    /**
     * {@inheritdoc}
     */
    public function parse(string $file): array
    {
        $data = 
 php

// index.php

hp';

$configFactory = new \Rkulik\Config\ConfigFactory();
$customParser = new CustomParser();

$config = $configFactory->make('config.php', $customParser);

echo $config->get('hello'); // dlrow
 php

// config.php

return [
    'hello' => [
        'beautiful' => 'world',
    ],
];
 php

// index.php

Rkulik\Config\ConfigFactory();

$config = $configFactory->make('config.php');

echo $config->get('hello.beautiful'); // world