Easy Configuration Management Library
if your are writing a WordPress theme or a php application obviously you will have some configuration values. you will create a file with bunch of variable and constants and include every file in your script which is not an intuitive way as I feel. I like the way laravel handles configuration values. but we can't use laravel in our WordPress themes that's why I wrote Config
to install config in your project you just need to run this command
$ composer require azi/config
after installing config you will need to create a directory named config
in root of your project
where your composer.json
lives
in this directory you can store your configuration files. i.e database.php
or site.php
lets say you want to store your database configuration values here. you will have to follow the following steps.
- create a file called
database.php
- return your configuration values form that file like
return [
'mysql' => [
'host' => '127.0.0.1',
'username' => 'root',
'password' => 'secrete'
]
];
- access the values from anywhere in your application like
// will return 127.0.0.1
$host = Azi\Config::get('database.mysql.host');
with this package you will also get a little helper function to access values you can also write the above code like this
// will return 127.0.0.1
$host = config('database.mysql.host');