Yii silently crashes

Hi,

I’m new to Yii, it’s great but one thing makes me really angry. When I made a mistake, which is not syntax error or null reference (e.g. I use function that does not exist) - the Yii just stops. If it’s in view script - its trackable, because I can see where HTML stops rendering. But when it comes to controller or model - I receive 500 Internal Server Error.

I generated application with yiic command. I have the YII_DEBUG set to true and the YII_TRACE_LEVEL to 3.

How to fix this?

can you post the complete content of your index.php?

You should get a very nice stacktrace of what happended instead of error 500 when YII_DEBUG is true.

Here: http: / / pasteit.com/17828 (I’m not allowed to post links yet).

I get the pretty debug for these errors on both localhost and my hosting (code in actionIndex in the SiteController):

  • $this->unknownMethod()

  • $this->nothing->getSomenthing()

I get 500 Internal Server Error on hosting and pure PHP error on localhost, when:

  • do the syntax error (e.g. forget ";")

  • call to undefined function (e.g. undefinedFunction())

I actually solved this problem with


error_reporting(E_ALL);

ini_set('display_errors', 'On');

in my index.php, but I only receive a pure PHP error in both localhost and hosting. Is this normal?

Yes, it’s OK. There’s no good way to catch such errors in PHP.

I was hunting through the web trying to understand why this bloody framework doesn’t give me a helpful error before crashing! It’s really annoying

thanks to vojtek above. Thanks error reporting setting is some consolation.

In Yii2 we’ve solved catching all kind of errors, even the ones that normally aren’t catchable so it should be a big step forward in this regard.