$config = new \Zend\Config\Config(include 'config.php'); $databaseConfig = $config->get('db'); $host = $databaseConfig->get('host'); $username = $databaseConfig->get('username'); $password = $databaseConfig->get('password'); $databaseName = $databaseConfig->get('database');
$config = new \Zend\Config\Config([ 'db' => [ 'host' => getenv('DB_HOST'), 'username' => getenv('DB_USER'), 'password' => getenv('DB_PASS'), 'database' => getenv('DB_NAME'), ] ]);In this example, we use environment variables to set configuration values for our database connection. This allows us to easily change these values depending on the environment our application is running in. Package Library: Zend Config is a package library that provides a set of classes to manage configuration data in PHP applications. It is part of the Zend Framework and can be installed using Composer.