Pragmatism in the real world

ZendTool providers in ZF2 (dev1)

I’ve started playing with the development versions of ZF 2.0 and one of the first things I thought I’d do was to port Akrabat_Db_Schema_Manager. It turned out to be reasonably easy.

All I needed to do was rework my use of ZF components to use the new ZF2 ones. Whilst I was at it, I also converted it to use namespaces. I also had to reorganise the http://github.com/akrabat/Akrabat library so that I could have ZF1 and ZF2 code in it.

The DatabaseSchemaProvider

Before:
<?php

class Akrabat_Tool_DatabaseSchemaProvider extends Zend_Tool_Project_Provider_Abstract
{
//etc

After:

<?php

namespace Akrabat\Tool;

class DatabaseSchemaProvider extends \Zend\Tool\Project\Provider\AbstractProvider
{
//etc

The filename, DatabaseSchemaProvider.php, is the same and the file lives in the Akrabat/Tool directory as before.

You can see the class now extends from ZendToolProjectProviderAbstractProvider. This shows one of the consequences of moving to namespaces: with a one to one mapping, we would have ended up with a class called Abstract which isn’t allowed, so the classname has been changed to AbstractProvider. There are a fair few class name changes like this throughout ZF2, so expect to do a bit of file browsing :)

The rest of the changes that I had to make are exactly the same type namespace conversions and that was all I had to do. Maybe when the autoloader is updated, then more changes will be required and if so, I’ll no doubt write it up!

The new AkrabatDbSchemaManager is available on my github account. The readme contains instructions on how to set it up with ZF2 too.

One thought on “ZendTool providers in ZF2 (dev1)

  1. I have a problem with the controllers in the modules, i've generate the controllers with the zf command line tool but i get the error message 'Invalid controller class("ApplicationErrorController")'

    [code]
    <?php

    /** @namespace */
    namespace Default;

    class ErrorController extends ZendControllerAction
    {

    }
    [/code]

    anyone an idea how i can solve this?

Comments are closed.