Category: PHP


Speed up database access when using Zend_Db and Zend_Cache

July 27th, 2010 — 3:34pm

Before it performs a query, Zend_Db first needs to look up the metadata for the table.

You can easily store the results of the metadata lookups in the cache.

Assuming you already have a valid Zend_Cache object, add the following line to the bootstrap:

Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);

That’s it.

Comment » | Uncategorized, Zend Framework

Zend Framework: Optimizing Custom Routes

June 2nd, 2009 — 2:26pm

Very nice article on how to improve the performance of custom routes in the Zend Framework.

If you use ‘em, read this…

http://blog.fedecarg.com/2008/07/15/improving-the-performance-of-zend_controller/

Comment » | PHP, Zend Framework

Zend Framework: Modular Structure

October 12th, 2008 — 9:01pm

After searching for a long time I still couldn’t find any tutorials on how to set up my directories and code to enable a nice tidy logical folder structure that contains each module of a larger application.

The standard (non-modular) structure is as follows.

web_root/
    application/
        controllers/
        views/
            scripts/
        models/
    library/
    htdocs/

To use a modular structure is actually very simple.
Create a ‘modules’ directory under the ‘application’ directory.
You guessed it – place all your module directories here. In each module directory is a standard MVC structure that you would normally see below the ‘application’ dir.

For example say you had a public area and an admin area. This is how it might look.

web_root/
    application/
        modules/
            admin/
                controllers/
                views/
                    scripts/
                models/
            guest/
                controllers/
                views/
                    scripts/
                models/

    library/
    htdocs/

This can be extended for as many modules as you wish.

You now need to declare where the modules are located to your scripts. There are a few ways to achieve this, but by far the easiest is to add one line of code to the bootstrap file.

$front->addModuleDirectory('/web_root/application/modules');

Thats it, unless you are using Zend_Layout which I plan to cover in part two of this tutorial.
For more information look in the Zend Framework Manual.

Comment » | PHP, Zend Framework

Book Review: Guide To Using Zend Framework

October 11th, 2008 — 3:48pm

A decent book from Cal Evans published by php|architect.
Based on ZF RC 1.5 so out of date now, but some useful stuff on using web services.
Because it was released as Zend_Layout was only a week old there is a very small appendix on the subject.
Also some of concepts in the ‘Globals secret-super-ninja class’ could now be better executed using Zend_Registry.
On the whole not bad, but until it’s updated you are better reading the docs and the various tutorials out there.

7/10

Comment » | PHP, Zend Framework

Back to top