Zend Framework 2.0

Zend\Tool 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 \Zend\Tool\Project\Provider\AbstractProvider. 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 Akrabat\Db\Schema\Manager is available on my github account. The readme contains instructions on how to set it up with ZF2 too.

Author: Rob…

State of Zend Framework 2.0

The past few months have kept myself and my team quite busy, as we’ve turned
our attentions from maintenance of the Zend Framework 1.X series to Zend
Framework 2.0. I’ve been fielding questions regularly about ZF2 lately, and
felt it was time to talk about the roadmap for ZF2, what we’ve done so far,
and how the community can help.

Continue reading “State of Zend Framework 2.0″

Author:

by News Robot on August 28, 2010 in News, No Comments »
tags:

The Future of Zend Framework

As the Zend Framework community works on the final release for Zend Framework 1, version 1.11, due out in late September or October 2010, it is time to look to the future.

Version 2.0 of the Zend Framework will bring around some significant changes and 2.0 code will not be backward compatible with the 1.x branches. That isn’t to say that bringing a ZF 1.x application up to speed with ZF 2 is impossible, but it will take solme reworking and plenty of testing.

The primary goals of Zend Framework 2 include increasing overall performance of the framework, making components more consistent in their usage (standardizing constructor options, fluent interfaces all around, etc), and migrating to PHP namespaces.

The last point perhaps represents the biggest shift. Introduced in PHP 5.3 (5.3 will be the minimum version supported by ZF 2), namespaces are a way to simplify coding while keeping it logically separated into components. For example, using Zend Framework 1, you might use a component in the following way:

$db = new Zend_Db_Adapter_Pdo_Mysql($options);

The naming of Zend components is necessarily complex and can lead to long winded code. Namespaces allow you to tell PHP to use a particular namespace, so that any reference to a class can be greatly simplified. Using namespaces, the above code could be rewritten as:

namespace 'Zend/Db/Adapter/Pdo';
$db = new Mysql($options);

It may not look like much, but using namespaces can really increase the readability of your code.

When should we expect Zend Framework 2? Currently, development is in the earliest stages and many changes are still
being discussed by the community. Don’t expect a final, production ready release before Spring 2011.

In anticipation of the the upcoming 2.0 branch, I would recommend becoming familiar with namespaces and upgrading your server to PHP 5.3.

Author: nick
Source: ZendCoding

by News Robot on August 27, 2010 in News, No Comments »
tags:

Richard Thomas’ Blog: ZF please before you go 2.0 gunho please clean out the attic

Richard Thomas has pointed out very important issues in Zend Framework – long term support and maintenance of components.

A good example is Zend_OpenID, its stuck in OpenID 1.0 land and hasn’t had any real updates in almost in almost a year. Considering how popular OpenID is on the web these days having such a library so out of date reflects very badly on the project.

These are very strong words, but unfortunately it’s also true. Development of some components looks like abandoned. What can we do about it? If you have any idea let the community hear your voice.

Giorgio Sironi’s Blog: How to eliminate singletons

Singletons are often compared to same class of evil as goto instruction, or more familiar for PHP developers $GLOBALS. This thesis is hard to understand since Singleton is most basic and commonly know pattern. Even if one agrees with arguments, might find hard to eliminate singletons from own code. Giorgio Sironi shows that eliminating singletons is not that hard.

It is actually very simple to eliminate singletons: just force the components to ask for what they need in the constructor or via setters or via inject*() methods, instead of looking up a singleton trough a static method only to obtain a reference. Once this fundamental decoupling is achieved, the hard part is tackling the construction problem: Zend Framework has a big codebase and writing a factory (manual dependency injection) for every use case is not viable. Thus, automatic dependency injection needs to be called upon. There are many xml-configured dependency injection frameworks for php to incorporate, but let’s show a simple example of how they works.

The tutorial was split into two parts. First one presents basic solution for the problem. Second part addresses some problems related to objects having shorter lifetime than application-wide ones.