Developing software in the Real World

Zend Framework: Test Code Upgrade to 0.1.2

I’ve upgraded my test application to Zend Framework 0.1.2 and these are my notes:

I’ve changed my directory structure to match the one suggested in the manual. This involved moving a few files around, but nothing to major. I also changed all the paths in index.php to point at the new places.

The new directory structure looks like:

ZF Test Directory Stucture for 0.1.2

As per the manual suggestion I moved my Akrabat_Action and Akrabat_Router classes to library/Akrabat/Controller/ and so renamed Akrabat_Action to Akrabat_Controller_Action and Akrabat_Router to Akrabat_Controller_Router to match their new locations for zend::loadClass().

I fixed up Akrabat_Controller_Router to use Zend_Controller_Dispatcher_Token.

The $adapterName for Zend_Db::factory() is now ‘pdoMysql’.

Obviously IndexController now extends Akrabat_Controller_Action and I renamed all the action functions from xxx() to xxxAction().

And that was it!

This is the latest zip file: zf_test_v3.zip

11 thoughts on “Zend Framework: Test Code Upgrade to 0.1.2

  1. nice work…

    i've spent a few hours looking at the controller, et al today and have taken the opportunity to put something together that suits my own needs.

    keep up the good work, and a big thanks to all who contribute, les

  2. Depending on the development progress of the framework, it's probally going to be a big part of my next project. It's great to see how other people are using it (even within small test applications)

  3. Is it best practice to extend the Action and Router classes? I expect that since ZF is still very early on in development, that the base classes will change and this will break your implementation. Do you suggest that we extend Action and Router as needed /if neccessary?/

  4. I think it's too early to tell what best practice will be. I fully expect that once the new Routing stuff goes in, then my extensions to the Router will become unncessary.

    I expect that specific projects will extend the Action class though it all depends on how the view gets tied to the actions by default. With any luck, it'll be mostly seamless so that extending the Action is rare rather than required like now.

    It's 100% certain that my implementation will break on nearly every new release of ZF at the moment :) but then this is all is pre-pre-pre alpha at the moment.

  5. i am developping an application which require multiple selects. that's why i think extending Zend_Db_Table is not helping me. i was wandering if u can give me some workout for this. many thanks in advance.

  6. ex:

    let's say there are 2 tables: dis (id) and loc (id,jid)
    query: SELECT dis.* FROM dis JOIN loc ON dis.id=loc.jid;

    in models/Loc.php: class Loc extends Zend_Db_Table;

    i made a method like this

    function findJudetFromMultiple($fields, $join, $on, $where = null) {
    $db = Zend::registry('db');
    $sql = "SELECT {$fields} FROM {$join} JOIN {$this->_name} ON {$on}";
    if (!is_null($where)) {
    $sql .= "WHERE {$where}";
    }
    $res = $db->query($sql);
    return $res->fetchAll();
    }

    using Zend_Db object from registry, not using Zend_Db_Table (except for $this->_name)

    i was thinking of using more Zend_Db_Table and less Zend_Db… but no results. maybe you have some ideas. thanks

  7. Hey,

    Given that you wrote this 2 years ago I am guessing that a lot has changed. This was just what I was looking for but how applicable is it now ?

    Thanks,

    James

Thoughts? Leave a reply

Your email address will not be published. Required fields are marked *