Why to use Zend Framework?

No Comments

Why you should use Zend Framework. Here are some benefits, which motivates web programmers to use it :)

Zend Framework is a fully object-oriented framework. So there are a lot of classes and interfaces which can be extended and implemented.

Based on MVC Architecture and consist of collection of class and components. Big library of components and ability to integrate new ones or customised existing. Because of loose coupling it is very easy to do customisation and integration of components.

Integration with ORM (i.e Doctrine) makes it more powerful. It is very easy to integrate other frameworks and templating engines such as JQuery, Smarty.

Zend Framework makes it easy to do TDD via Zend_Test, which uses PHPUnit, a popular unit testing framework. PHPUnit lets you test not only your Controllers, but also your library and model functions.

Because of its multiple components, complexity, and fully object-oriented approach, Zend Framework has a very steep learning curve. It becomes easier to learn due to the comprehensiveness of its documentation and community.

Difference between Zend_debug and Zend_log

No Comments

Zend_Debug is a very simple component that provides a quick way to dump variables to screen for ad-hoc debugging.

Zend_Debug::dump($_Server, 'SERVER VARS', true);

Above command will dump out the $_server array with the label SERVER VARS

Zend_Log
Zend_Debug is very good for ad hoc debugging. For more permanent debugging, we can use Zend_Log. Zend_Log has some greate features, including Firefox Firebug stream writer that enables us to log to the Firebug console.
$log = new Zend_Log(
new Zend_Log_Writer_Stream('php://output')
);

Multiple loggers and the ability to define your own events and log levels are also included in its features.

Difference between render and partial

No Comments

$this->render ('topnav.phtml')
$this->partial('topnav.phtml')

Render has the same variable scope as the script from which it is being called. Therefore, we must be careful of variable clashes. while partial helper render a view script within its own scope. There is one downside to partial helper though, it has to clone a lot of objects to get the view into its own scope, which means there is a performance hit while using it.