Upgrading Zend Framework 2.5.0 to be compatible with php 7

Hi there, I’ve got a site using Zend Framework 2.5.0. It runs on Php 5.6. I’d like to migrate to Php 7.x, but it seems ZF 2.5.0 is not compatible with Php 7.x.

I’ve read in ZF blog (PHP 7.2 Support! - Blog - Zend Framework) that ‘you should be able to perform a composer update to get versions that support PHP 7.2.’, but I don’t know whether I need to change something in composer.json file beforehand.

Any help with this?

Thanks in advance.

You should be able to run composer update with any 2.x series of zendframework/* components, and get compatible versions.

In practice, make sure your dependency declaration in composer.json uses SemVer-compatible range selectors.

See https://getcomposer.org/doc/articles/versions.md#writing-version-constraints

My suggestion would be to upgrade the dependencies individually, and run your unit/integration/e2e test suite against that, at every dependency update: that’s the safest path forward :slight_smile:

Thanks for the quick response.

So, do I need to change anything in composer.json before running composer update? Maybe php version? Right now, the require part is like this:

"require" : {
	"php" : ">=5.5",
	"zendframework/zendframework" : "~2.5",
	"masterexploder/phpthumb" : "^2.1"
}

You can try composer update and will find if any dependency issues with any of the packages.
Note your previous versions in case if you need to rollback.