Fastest config ever
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
tests
.gitignore
.travis.yml
composer.json
readme.md

readme.md

Sphido / Config

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Sphido config loading configurations as pure PHP arrays/objects it's doing only array_replace_recursive!

  • no obscure config file parsers
  • no extra config file formats
  • no unnecessary code
  • no power loss

Setup values

It's simple, just call config() in your index.php to setup values

/app/config(
	[],
	include __DIR__ . '/config.base.php',
	include __DIR__ . '/config.stable.php'
);

Your config.base.php need return some array values e.g.:

return [
	'example' => 'value',
	'invokeme' => function() {}
	'constant' => PHP_VERSION,
	'execute' => $a + $b
	'object' => (object)['a' => 'b', 'c' => 'd']
	'array' => ['a' => 'b', 'c' => 'd']
];

Read and Write

Then simply read and write any values:

/app/config()->example = 'save'
echo /app/config()->example; // will print save

It's pure PHP you can store whatever you need:

/app/config()->invokeme = function() { return 'something'};
call_user_func(config()->invokeme);

Reinit config values

Sometimes you can need change whole config content in runtime

/app/config(); // you can init empty config
/app/config(['oldConfigValues' => 'This is old content']);
/app/config(['reinitValues' => 'Reinit again...']);
/app/config()->reinitValues;