PHP code example of burzum / cakephp-config-objects

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

    

burzum / cakephp-config-objects example snippets


class Foo(array $config);

class Foo(FooConfig $config);

use Burzum\ObjectConfig\Config;

class FooConfig extends Config {

	protected $_defaultConfig = [
		// Set your default values here
	];

	/* Your setter / getter methods go here */
}

$config = new FooConfig();
$config->setBar('some-value);

class Foo {

	protected $config;

	public function __construct(FooConfig $config)
	{
		$this->config = $config;
	}
}

$foo = new Foo($config);

class Foo {

	protected $config;

	public function __construct(array $config = [])
	{
		$this->config = FooConfig::createFromArray($config);
	}
}

$config = new Config();
$config['arrayaccess'] = 'value';

echo $config['arrayaccess'];

$configArray = $config->toArray();