Migrating ZF2(v2.2.1) to Laminas

Hi All,
How to migrate ZF2(v2.2.1) project to Laminas?

My application is ZF v2.2.1, don’t have vendor folder but have only library folder which has all the packages like Zend-authentication, Zend-Barcode etc. I have followed the Migration steps from Migrate to Laminas.
I ran the migration command over my ZF2 application. After running migration command, I have got many package abandoned errors (For ex: Package zendframework/zend-authentication is abandoned, you should avoid using it. Use laminas/laminas-authentication instead). So, I have downloaded the recommended packages like laminas-authentication, laminas-barcode etc. Now, I am having Library folder and the Vendor folder. I want to understand few things:

  1. The only change I see after migration is the vendor folder is newly added and all other files of ZF2 remains the same. But the actual Laminas MVC files are different. So, what is the use of this migration steps link?(Migrate to Laminas). Is my application really migrated to Laminas and will I get all the security updates in future through composer update?
  2. When running the application in browser, I still see my application uses the packages from library folder. Am I want to rewrite all the modules to use Vendor folder?(For ex: /library/Zf2/Zend/Authentication —> /vendor/laminas/laminas-authentication). If so, it doesn’t seems like migration. It looks like upgrading each files to laminas.
    Please guide.

Hello Dev_Inc,

I have blog post about migration, it should help.

Hi tomstryja,

Thanks for sharing the blog link.

The blog says to migrate from ZF2 to ZF3 but does not specify any ZF2 version. Because my current version is ZF v2.2.1 and the ZF v2.5 has many significant changes. Few recommendation from Laminas community says that I need to migrate from ZF v2 to v2.5 and then to ZF3.

  1. Can I migrate directly from ZF v2.2.1 to ZF3 referring your blog link?
  2. I understand that you have migrated couple of projects from ZF2 to ZF3. May I know from which version of ZF2 you converted to ZF3?
  3. Which is the best approach to follow and complete with less effort and quickly?
    a. Migrating from ZF v2.2.1 to v2.5 and then to ZF3 and then to Laminas
    b. Upgrading from ZF v2.2.1 to actual Laminas skeleton application by rewriting every code

Please suggest.

Hi Dev_Inc,

if I remember you should migrate from even below 2.5 without big struggle to ZF3. The key is to have ContainerInterface available … this was since 2.6.0 required by zendframework/zend-servicemanager
Most changes is done in controllers and module.config.php and module dir structure.
Just pick one module in your app and start refaktoring … like I descibe in the GitHub article. You should be able still run refactored version under ZF2.

After you refactor app to 2.6.0+, you will just make small update in controller factories, after that you should be able to run ZF3. Than use that migration command tool to Laminas.

Hi tomstryja,

Thank you for the suggestion.
But I could not find Zend v2.6.0 from this github Repo. It has till v2.5.3 and moved to v3.0.0. I tried from composer using “zendframework/zendframework”: “~2.6” but it does not work.

Can you please suggest a way to download Zend v2.6.0

Starting from ZF 2.5, the main zendframework/zendframework package is only a meta-package requiring all the others.

A composer update should suffice.

Thank You @ocramius.