Wednesday, February 11, 2009

Database Operations Analysis using zend_profiler

The Zend Framework offers its own logging solution for all SQL queries to profile what is run, and how long it takes to execute, using Zend_Db_Profiler. The profiler can be enabled by passing an option called "profiler" with a boolean TRUE value with the options when constructing a database adapter. Thereafter you can instantiate the Zend_Db_Profiler class and use a variety of methods to examine how many queries were profiled, how long they took in total to execute, and retrieve an array of query profiles on which to perform a more in-depth analysis using the accompanying filters. There's even a special Zend_Db_Profiler_Firebug class so you can view profiling data on the fly through the Firebug console in Firefox.

Usage
in Bootstrap file

// turn on profiler:
$db->getProfiler()->setEnabled(true);

in Action before all queries

$profiler = $db->getProfiler();


Bottom of the function


foreach ($profiler->getQueryProfiles() as $query) {

echo '
'.$query->getQuery();
echo ' TIME: ' .$query->getElapsedSecs()." Seconds";

}

It will list the Connection Time and all other executed queries with taken time


Tuesday, February 3, 2009

Zend Framework v1.7.4 is released

The latest update to Zend Framework was just released today and is available for download:

http://framework.zend.com/download/latest/

31 separate issues were fixed in this release. A full list of all issues addressed may be found here:

http://framework.zend.com/issues/secure/IssueNavigator.jspa?requestId=10944

Thursday, January 29, 2009

Manage ‘Invalid controller specified’ Error with Default controller

It’s quite obvious that the site users will go wherever they want with our domain name. If you work with Zend frame work and calls a non existing Controller then it causes showing an ugly error message on the screen telling the Controller not found.

We have the function __cal() to catch all the non existing function within a controller, but we couldn’t go for a default controller. We have to use Plugins to manage this section. In Zend Framework, plugins are used to listen for certain events in the front controller.

preDispatch() Event
This event will fire prior to dispatching an individual action. So before that we can check the existence.

Action helper code

The class location
library/Zend/Controller/Action/Helper/ ControllerSetup.php


class Zend_Controller_Action_Helper_ControllerSetup extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
require_once("Zend/Controller/Front.php");
$dispatcher = Zend_Controller_Front::getInstance()->getDispatcher();
if (!$dispatcher->isDispatchable($request))
{
$request->setControllerName('Index')
->setActionName('index')
->setDispatched(false);
}
}
}


Include the class into bootstrap file

Zend_Loader::loadClass('Zend_Controller_Action_Helper_ControllerSetup');


Initialize the Controller Front Object

$frontController = Zend_Controller_Front::getInstance();


Register the Plug In

$frontController->registerPlugin(new Zend_Controller_Action_Helper_ControllerSetup());


That’s it

Here I redirected to the Index Controller and Index Action, You can make your own 404 error page and set to that page easily.


If you use an alternative to this solution, share it with us in the Comments section!

Wednesday, January 28, 2009

Caching with Zend_Cache

Pádraic Brady has been posting a 3(ish) part series all about page caching with Zend Framework:

Page Caching is the process of caching entire generated HTML documents for a period of time so that the expensive task of dynamically generating them is avoided for that period. Done correctly, it should completely bypass the Zend Framework MVC stack. This can net you incredible results!

It’s a long read, but very well worth it.

Monday, January 19, 2009

How to Study for the Zend Framework Certification Test

In this article, Alan Seiden gives away 4 secrets on how he prepared for the Zend Framework Certification exam, and passed it. This goes a little deeper than “study hard and often”, and gives you links to excellent resources for when you are prepping for the exam. If you still have doubts about wether you can pass the exam, you sure want to read this article, and get yourself certified. With these steps, there are no more reasons why you can’t be a Zend Framework Certified Engineer too!

Friday, January 16, 2009

WebResourcesDepot.com: 19 Promising PHP Template Engines

Looking for a good templating engine for your next PHP application? Be sure to check out this great list on the WebResourcesDepot site for a pretty comprehensive list.

PHP template engines are used widely to seperate the code & the layout. PHP makes a website easier to maintain/update & creates a better development environment by enabling developers & designers to work together easier. It sure has some drawbacks which is generally the performance (most libraries offer great solutions there) & need to learn a new syntax (not always).

Some of the engines included in the list are:

Wednesday, January 14, 2009

YensDesign.com: How to Validate Forms in both sides using PHP and jQuery

The YensDesign blog has a recent post that steps you through the entire process (down to every detail in the code) of making a form validation script that checks things on both sides - PHP for the server-side and jQuery on the client.

The form they create (a href="http://yensdesign.com/tutorials/validateform/">demo here) is a generic "send a message" form with fields for name, email address, passwords and the message itself. All code - both PHP and Javascript - is provided.

Monday, January 12, 2009

The Semi-Official Zend Framework Pear Channel

For the past few months, the ZF team has been playing with the idea of releasing ZF from a PEAR channel. Over the past 2 years, we have seen a few channels distributing ZF that have pop up here and there.. so that lead us to believe there is an itch that needs scratching.

Find More details here
http://ralphschindler.com/2009/01/07/the-semi-official-zend-framework-pear-channel

Another Object Oriented PHP5 Web Software Framework

Artisan System is a new object oriented PHP5 framework with most of the features you'd expect from a framework (database abstraction, MVC, etc). The main purpose of Artisan is to be an e-commerce/event management framework.

For more information and download http://artisansystem.com/

Sunday, January 11, 2009

A free Zend Framework Book

Great news for those who are looking for info about Zend Framework! Pádraic Brady announced the release of his free online ZF book “Zend Framework: Surviving The Deep End”. This book is completely free - he’s using some help from go...
http://www.survivethedeepend.com

Saturday, January 10, 2009

Zend Framework Performance Guide

Zend framework managed to provide some concrete strategies for improving the performance of your Zend Framework applications. The guide is presented in a "Question and Answer" format, and broken into areas of concern. Click Here to read the full documentation.

Friday, January 9, 2009

Zend Framework 1.7.0 is now available

Zend Framework 1.7.0 is now available from the Zend Framework download site:
http://framework.zend.com/download/latest