I am creating a reusable app, which requires some configurations stored in config.php
. This configuration file does not have any function, but the configuration are returned as an array, eg
<?php
return [
'db_name' => 'db_name',
'password' => 'password',
........
];
I was hoping to create a function which includes this config file, and get each config set. An example is laravel config()
function which returns a configuration value. Is there any way to acheive this?
I have tried
$filename = 'config.php';
include $filename;
$contents[] = file_get_contents($filename);
but this just gets whatever is in the file as a string.