Skip to content

OzzyCzech/config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sphido / Config

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;