Another blog post for self documentation 😉
Debugging:
Create a init() method in the controller. Put the following codes to disable the layout and turn off view rendering. Now, use print_r(), var_dump() or try…catch whatever you like 🙂
Please note: please make sure if you have any layout enabled already, if you don’t have one, trying to disable the layout will obviously go wrong. In that case, uncomment the respective line.
1 2 3 4 5 6 |
public function init() { /* Initialize action controller here */ $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); } |
Even without all these hassles, anywhere in your controller you can use Zend_Debug::dump() which works like var_dump(). But it won’t work in case there is an Application Error (a fatal error somewhere). So, try…catch is a better debugging solution when you can’t trace the source of the problem. For a quick debugging, use Zend_Debug::dump().
Loading Custom Ini
Create a ini file in the “application/configs/” directory. Lets name it mydata.ini. Then create a block of data like this:
1 2 3 |
[blog] name = My Blog url = http://masnun.me |
Now, you can load these configuration anywhere using the following codes:
1 2 |
$mydataConfig = new Zend_Config_Ini("../application/configs/mydata.ini", "blog"); Zend_Debug::dump($mydataConfig->name); |
The second parameter of the Zend_Config_Ini constructor loads a specific block from the ini file.