I'm wondering if anybody has thoughts on how to migrate a project from zf1 to 2. I'm on a projects with a fairly large code base and simply replacing zf1 with zf2 all at once doesn't really seem practical. I think it would be nice if there was a way to have an intermediate stage where we use both version 1 and 2 while we phase out version one. I was thinking this could be possible using a classpath autoloader. I figure that should be able to load the correct class since the class map would recognize the different class names based on the different namespace separator. Anyways, I haven't really given this much thought but I was wondering if anybody else has and whether or not the only practical solution is to use one or the other.
Have fun or die trying - but try not to actually die.
(on Monday, 13 February 2012, 02:25 PM -0800):
It's actually not just a matter of autoloading -- and even with
autoloading, there are different approaches. :)
To give an idea of autoloading approaches, check out Rob Allen's blog
post from today:
If you read it closely, you'll see the ZF2 autoloaders are capable of
loading classes from both ZF1 and ZF2 side-by-side (since the former
uses vendor prefixes, and the latter uses namespaces).
However, any migration is actually more than simply changing where and
how classes are found.
If you have written good, solid domain models, you should be able to
re-use that code within the new MVC fairly easily -- in fact, most of
your view scripts should continue to work well, too. The main thrust of
your work, then, will be migrating your controllers and any plugins
and/or action helpers you're using to the new MVC architecture.
One way to do this is to move a little at a time, and use rewrite rules
to direct different sections of your application to different bootstrap
scripts (usually your index.php -- but in this case you'd have one each
for ZF1 and ZF2).
I've created a proof-of-concept that emulates the ZF1 MVC on top of ZF2,
but it's incomplete at this time; once we get a stable MVC API (which
will be within the next 3 - 9 weeks, hopefully), myself or my team can
perhaps start working more in earnest on this; this will help make the
transition a little easier, hopefully.
Sorry there's no clear-cut answer right now!
Matthew Weier O'Phinney
Project Lead | matthew*******
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/ zf-matthew-pgp-key.asc
Info: http://framework.zend.com/ archives