dez-php / dez-configuration
DezPHP - Config
v1.3.0
2016-04-14 17:18 UTC
Requires
- php: >=5.5
This package is not auto-updated.
Last update: 2024-12-25 10:04:25 UTC
README
Usage
examples
<?php include_once '../vendor/autoload.php'; $config = new Dez\Config\Adapter\NativeArray('./app.php'); $config->get('app')->get('path')->get('static'); $config['app']['path']['base']; $config->app->path->base; $config->app['path']->get('static'); $appJson = $config['app']->toJSON(); $pathArray = $config->app['path']->toArray();
using adapters
<?php include_once '../vendor/autoload.php'; $config = new Dez\Config\Adapter\NativeArray('./_config.php'); $configJson = new Dez\Config\Adapter\Json('./_config.json');
using static method factory
<?php use Dez\Config\Config; include_once '../vendor/autoload.php'; // from ini file $config1 = Config::factory('./_config.ini'); // from native php file $config2 = Config::factory('./_config.php'); // from json file $config3 = Config::factory('./_config.json'); // from native php array $config4 = Config::factory([ 'app' => [ 'site' => 'test.com', 'path' => [ 'static' => '/assets', 'base' => '/' ] ] ]);
merge config objects
<?php use Dez\Config\Config; include_once '../vendor/autoload.php'; $config = new Dez\Config\Adapter\NativeArray('./connection.php'); $configIni = Config::factory('./app.ini'); $configJson = new Dez\Config\Adapter\Json('./site-setting.json'); $globalConfig = $config->merge($configIni)->merge($configJson);
extra methods
<?php include_once '../vendor/autoload.php'; $config = new Dez\Config\Adapter\NativeArray('./connection.php'); $config->toArray(); $config->toJSON(); $config->toObject();