Why most frameworks (at least in PHP. I suppose in other languages, too) use the environment variables to set a corresponding configuration parameter and then access the value through a config object/function (e.g config('mysql.passqord') or $config->get('mysql.password') ). I won't argue on whether environment variables are good or bad. Let's say we decided to put some configuration values in environment variables. What is wrong with directly reading the environment variable (e.g env('MYSQL_PASSWORD') ) in any place of your code you need them ?
Is it just that we want to have a unified way to access all configuration parameters ? Is there any other more important reason ?