I created a custom XML configuration file called config.xml and placed it in the configs directory in the Zend Framework. I want to use it in one of my controllers using Zend_Config_Xml. What I have is not working, and it says “An error occurred. Application error”. How do I read in a custom XML config file from a controller? This is what I have in my controller so far:
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
// action body
$config = new Zend_Config_Xml('config.xml', 'staging');
echo $config->host;
}
}
Probably just the path you need to fix:
if not, check the error log to see what the actual error message is.
Edit: To do this in the bootstrap, the easiest (although perhaps not best) way is to add a new resource method and store the config object in the registry. Add this to your bootstrap class:
you can then access it later using: