PHP code example of rcm / config

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

    

rcm / config example snippets



    // Example of a config array as might be defined in ZF2 config
    'Reliv\RcmConfig' => [
        'myCategory' => [
            '_DEFAULT' => [
                'myPropertyName1' => 'my value',
                'myPropertyName2' => ['my value1', 'my value2'],
            ],
            'myContext' => [
                'myPropertyName1' => 'my value over-ride',
            ]
        ]
    ],
    // Example of defining a model for a category
    'Reliv\RcmConfig\Models' => [
        'myCategory' => \Reliv\RcmConfig\Model\ConfigModel::class,
    ],


    /** Using /Zend\ServiceManager/ServiceManager as $serviceLocator */

    $configService = $serviceLocator->get(\Reliv\RcmConfig\Service\ConfigService::class);

    $value = $configService->getValue(
        'myCategory',
        'myContext',
        'myPropertyName1'
    );
    /** Outputs: 'my value over-ride' */
    var_dump($value);
    
    $value = $configService->getValue(
        'myCategory',
        'myContext',
        'myPropertyName2'
    );
    /** Outputs: ['my value1', 'my value2'] */
    var_dump($value);
    
    /** Other Methods */
    var_dump(
        'getList',
        $cs->getList('myCategory'),
        'getAll',
        $cs->getAll('myCategory', 'myContext'),
        'getDefault',
        $cs->getDefault('myCategory'),
        'getListValue',
        $cs->getListValue('myCategory', 'myPropertyName1'),
        'getPrimary',
        $cs->getPrimary('myCategory', 'myContext')
    );