I’ve built a simple mvc application for educational purposes to improve my skills however right now i’m stuck trying to implement a config feature that will allow the array data file seen below to be accessed anywhere throughout the application.
I know i could simply set this array as a constant however i feel like that’s cheating and i would rather attempt a laravel / cakephp config kind of implementation. $app->config('application.name')
i feel like i’m overthinking this wayyy too much such as should i build a simple container, should i use static, should i create a function and just load the config.php file in each time but performance etc etc. but i would just really appreciate any help in implementing an extremely simple solution to be able to constantly access this files array.
Thanks so much.
config.php:
return [
'application' => [
'name' => 'Application Name',
'version' => '2021.1',
'timezone' => 'UTC',
'default_language' => 'en',
],
'core' => [
'environment' => 'development',
],
'database' => [
'default' => [
'driver' => '',
'host' => '',
'user' => '',
'password' => '',
'name' => '',
],
'idk' => [
'driver' => '',
'host' => '',
'user' => '',
'password' => '',
'name' => '',
],
]
];