7

I have a project built in Zend Framework 1. With PHP up to 7.1, it works fine. When I upgraded PHP on one of the testing servers, it shows an internal error:

Fatal error: Declaration of Zend_Rest_Route::assemble($data = Array, $reset = false, $encode = true) must be compatible with Zend_Controller_Router_Route_Module::assemble($data = Array, $reset = false, $encode = true, $partial = false) in /public_html/library/Zend/Rest/Route.php on line 52

It appears that both classes belong to the framework. Version of ZF1 installed is 1.12.18.

Is there a version of ZF1 compatible with PHP 7.2? Or is upgrade to ZF2 unavoidable to maintain compatibility?

TimSparrow
  • 899
  • 11
  • 21
  • ZF1 is compatible with PHP7 as you can see in [this answer](https://stackoverflow.com/a/35505427/4932315), but it seems PHP 7.2 breaks backward compatibility in many projects. In your case, the declaration in `Zend_Controller_Router_Route_Module` has one parameter that is not in the declaration in `Zend_Rest_Route` – Anthony Mar 02 '18 at 15:45

2 Answers2

13

Zend Framework 1 has reached its end of life, but some forks have been done. Shardj's one is compatible with PHP 7.3.

Anthony
  • 2,014
  • 2
  • 19
  • 29
  • 7
    Oh shit haha, I made that repo due to this post, now it has gone full circle – Shardj Apr 23 '19 at 13:54
  • 2
    @Shardj you made my day haha! Your repo is great and probably helps a lot of people! I thank your for beginning the circle! – Anthony Apr 23 '19 at 16:08
8

Yes, the error is caused by a tightening of PHP's inheritance model, so if the framework code is failing with this error in PHP 7.2 then the answer is that the framework is not compatible with 7.2, at least not without fixing this (and other similar) errors.

This error definitely looks like it's going to be a show stopper for you, and Zend 1 is no longer maintained, so I guess the simple answer is you're going to have to either upgrade Zend or not upgrade PHP.

Your other alternative would be to fork Zend yourself and fix the compatibility issues. Or there may be community forks by others who have done the same thing. I really wouldn't recommend that though. At some point you're going to have to bite the bullet and upgrade; it'll get harder to do the longer you leave it, so you may as well do it now.

Spudley
  • 166,037
  • 39
  • 233
  • 307
  • Thanks for the answer. Is version 2 currently stable? – TimSparrow Mar 02 '18 at 16:00
  • 1
    @TimSparrow The [version 3 is stable](https://framework.zend.com/blog/zend-framework-3-update-and-roadmap.html). So yes the version 2 is also stable. – Anthony Mar 02 '18 at 16:13
  • I've got versions of ZF 1.12 running fine with PHP version 7.2.6. I also have versions of ZF 1.11 not running fine with php 7.2.6. That's why I came here. – PiggyMacPigPig Jun 06 '18 at 15:59