25 Nov
Posted by Ganesh H S , Bangalore, India as zend framework
In the previous post about setting project environment setting http://ganeshhs.com/php/php-configuring-project-environment-using-ini-file , zend config plays a vital role in initializing the environment variables and by default, configuration data made available through Zend_Config are read-only.
Lets write the ini configuration file application/config.ini
[staging] db.adapter = PDO_MYSQL db.config.host = localhost db.config.username = mysql_user db.config.password = mysql_password db.config.dbname = mysql_database show_errors = true [production] db.adapter = PDO_MYSQL db.config.host = mysql_host_name db.config.username = mysql_user db.config.password = mysql_password show_errors = false
Lets add the following code in boot strap file public/index.php
<?php
require_once 'Zend/Config/Ini.php';
$config = new Zend_Config_Ini('/path/to/config.ini', 'staging');
// in our project we will be using path application/config.ini
// Try printing host name
echo "Host Name: ".$config->db->config->host;
?>
Reference Links:
http://ganeshhs.com/php/php-configuring-project-environment-using-ini-file
http://framework.zend.com/manual/en/zend.config.theory_of_operation.html
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Jul | ||||||
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
RSS feed for comments on this post · TrackBack URI
Leave a reply