I saved some site configuration data in a config.json file with parameters such as database connection parameters and routes. Something like that:
{ "production" : { ... }, "test" : { ... }, "development" : { ... } }
And the content is loading:
$config = json_decode(file_get_contents('config'), true);
However, checking out some frameworks, I see direct use of PHP scripts to store the configuration:
<?php return array( 'production' => array( ... ), 'test' => array( ... ), 'development' => array( ... ) );
<?php $config = (require 'config.php');
Which approach is best?
source share