ZF 1.11 Migration to Laminas

I have an old project written in ZF1.11 that needs updating. Ideally up to PHP 7.2. It is in the older style without even any namespacing.
I have brought in the use of composer and the framework itself (as well as PHPUnit / DBUnit) is now in the vendor directory, as opposed to external includes. It uses the vendor autoloader for all external includes now.
I’ve followed the migration instructions here:

Put simply, nothing happened: none of the code was altered in any way, although laminas/laminas-dependency-plugin was added to composer.json.

Having read a couple of the topics in this forum, it seems to me that I have some work ahead of me to upgraded to ZF2 first. Is that the case or am I mistaken?

Hi, unfortunately you are right, you need to upgrade from zf1 to at least zf2 before you can make the move to Laminas.

Thanks for the reply, I was afraid of that.

There seems to be little in the way of documentation on the process or on ZF2 itself. I wonder if anyone can dig out some links for me or provide some advice on it from personal experience.

For example, If I am upgrading the ZF version and a non-trivial conversion is required, might it not just be better to do the upgrade to Laminas directly? I am sure that much of what it does is change the namespaces anyway.

You are probably right to go directly to Laminas as you are facing a lot of refactoring anyway. We recently moved from zf2 -> zf3 -> Laminas this year. ZF1 migration was done long ago by another developer so I don’t really know what was required there. The migration script would mostly change the keyword ‘zend’ to ‘Laminas’. It does a bit more and it does work well, I used it to go from zf3 to Laminas.

Changes that we needed to do would include:
Small change to directory structure as we moved from psr-0 (zf2) to psr-4.
Change to libraries such as validator libraries. Int became IsInt for example
Introduction of factories as use of serviceManager became more strict.

Also, if I remember correctly, I don’t think there was much of a migration path provided for zf1 to zf2, as it was a big enough change.

Again, thanks for taking the time to reply.

Perhaps my plan should be to create a skeleton Laminas application and migrate the ‘plumbing’ over first, then the modules one by one. My main fears are that the Zend_Db abstraction will break. Zend forms are also heavily being used, along with its validators.

The introduction of Composer is itself a big enough change, although the autoloading seems like a big leap forward.

1 Like