Categories
PHP

Zend Framework: Debugging and Loading Custom Ini

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.

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:

Now, you can load these configuration anywhere using the following codes:

The second parameter of the Zend_Config_Ini constructor loads a specific block from the ini file.