3

When producing a parse error, e.g. inside a Controller, ZF2 exception handler catches it and I only see

An error occurred during execution; please try again later.
No exception available

If I produce a parse error inside public/index.php I can see the plain PHP error in the browser, so PHP settings are correct.

How do I force ZF2 to show errors like this in dev mode?

1 Answer 1

5

Turns out I was using an old version of view/error/index.phtml (part of skeleton app) which was not prepared for errors of type Error (since PHP 7) and only handled errors of type Exception.

Had to change this line

<?php if(isset($this->exception) && $this->exception instanceof Exception): ?>

to this

<?php if (isset($this->exception) && ($this->exception instanceof \Exception || $this->exception instanceof \Error)) : ?>
2
  • since both Exception and Error class implements \Throwable, don't you think that's better to test the interface instead ? Commented Sep 22, 2016 at 9:19
  • @Hooli That’s a valid suggestion! The current Zend Skeleton Application explicitly checks for \Error and \Exception. However, it doesn’t look like they’re using any methods not defined in \Throwable.
    – Rob
    Commented Sep 23, 2016 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.