What are some best practices for implementing configuration classes in PHP projects?

When working on PHP projects, it is essential to have a well-structured configuration setup to manage settings and options effectively. One best practice for implementing configuration classes is to create a dedicated class that handles all configuration values, making it easier to access and modify them throughout the project.

class Config {
    private $config = [];

    public function __construct() {
        $this->config = include('config.php');
    }

    public function get($key) {
        return $this->config[$key] ?? null;
    }

    public function set($key, $value) {
        $this->config[$key] = $value;
    }
}

// Usage example
$config = new Config();
echo $config->get('db_host'); // Output: localhost
$config->set('db_host', 'new_host');
echo $config->get('db_host'); // Output: new_host