What are the drawbacks of following WordPress's approach to managing configuration in PHP?

One of the drawbacks of following WordPress's approach to managing configuration in PHP is that it often involves storing sensitive information, such as database credentials, directly in PHP files. This can pose a security risk if these files are not properly secured. To solve this issue, a better approach is to store sensitive information in environment variables and access them in your PHP code.

// Retrieve database credentials from environment variables
$db_host = getenv('DB_HOST');
$db_name = getenv('DB_NAME');
$db_user = getenv('DB_USER');
$db_pass = getenv('DB_PASS');

// Connect to the database using retrieved credentials
$pdo = new PDO("mysql:host=$db_host;dbname=$db_name", $db_user, $db_pass);