Re-load data from the database every web was accessed is not good for your server ‘health’. Zend Framework has a component named Hydrator. The Hydrator is a simple component to provide mechanisms both for hydrating objects, as well as extracting data sets from them.
To save database ResultSet into cache, You need to use Zend\Db\ResultSet\HydratingResultSet which can extract the resultSet into associative array. In this post, i will show you how to cache your database resultset into filesystem.
As developer, we should code as right as possible, but we must be aware that we can’t free from mistake. As long as web is accessed, we need to save the error that we not know-ing, and in next time, we resolve the problem. While using Zend Framework, you can use Logger component to ‘save’ your mistake(s) into file. In this post, i will show you the how to.
We need ZF2 Component named \Zend\Log which use two class : \Zend\Log\Logger and \Zend\Log\Writer\Stream. We need dispatch.error event too.
In production Application Environment, we should handle error page that user will be viewed. In Zend Framework 2, we can create our custom error page which show the user that the page is error, but not show them the exception.
Zend Framework provide a component named Zend\Captcha\Image that can be integrated with Zend\Form. It’s very fast to create a captcha image, and put to our form application. I will give an example to you how to work with it.
Sometimes, console is more interactive than GUI, and quicker to be executed. Console Application often need by cron job or generator for your datawarehouse that summarize your transactional data. It’s very easy in Zend Framework 2.
Just define console route, register controller invokables, set help for command line ( if necessary ), and run it.