I cannot be sure if this problem is partly due to the vagrant, however I have a Yii 1.x installation within a Vagrant box running Unix.
I am trying to force a simple PHP error such as a missing semi-colon in a controller, even though I am 100% sure I have a created an error I do not see the standard Yii error page with the stack trace. This has worked previously although it would seem something recent has stopped this working in this way.
The weird thing is - Yii is outputting the Database queries at the bottom of the script (this is intended but I cannot understand why Yii is only showing the DB queries.
My personal config looks as follows: (only showing part of it..)
I have tried the code below & check the logs but no joy
ini_set('display_errors',true);
error_reporting(E_ALL);
Can anyone suggest any ideas...
return array(
'yiiDebug' => true,
'yiiTraceLevel' => 6,
.....
'components'=>array(
'log' => array(
'class' => 'CLogRouter',
'routes' => array(
'web' => array(
'class' => 'CWebLogRoute',
'levels' => 'profile, trace, info, error, warning, application', // profile, trace, info, error, warning, application
'showInFireBug' => false
),
'file' => array(
'class' => 'CFileLogRoute',
'levels' => 'error, warning, watch', // error, warning, watch
'categories' => 'system.*',
),
array(
'class' => 'CProfileLogRoute',
'levels' => 'error, warning, trace, info, profile', // error, warning, trace, info, profile
),
),
),
),
So for instance... in one of my controllers I have the following code:
public function actionDelete($id)
{
$model = $this->loadModel($id);
5e55 // added error here on purpose
}
I would expect an error on the 2nd line in regards to the 5e55 that has no place being there, however rather than receive an error all I see is a white screen (plus the Yii application log that shows all the queries etc) - if I remove the yii config stuff to output queries I get a 100% white/blank screen.
I have tried adding various things to the index.php bootstrap file but without any joy, my config looks relatively normal but I cannot understand why the error is being reported to the browser or my logs.
You've done the right thing by setting
ini_set('display_errors',true);
error_reporting(E_ALL);
...but there are a few reasons why this might not actually take effect.
1) Error reporting might be getting turned off again by something 'later' in the script. Because these settings are basically just global variables anyone can set them and most frameworks have somewhere they're disabled. Depending on where your code got 'included' something else in the chain might well have called display_errors - false.
2) Changing settings can be disabled at run time. Your environment might have something like php_admin_flag directives to stop display_errors being turned on.
If you're able to get output at all, try running this to dump the state of all the ini settings:
var_dump(ini_get_all());
BUT what I think is probably happening is you have a small syntax error in one of your own files, and the interpreter is giving up on that code entirely. It's never executed, and so your display_errors setting isn't even getting run.
As others have suggested a look at your error logs will probably tell you what's going on.
Another hacky but useful way is to try and execute your files on the command line and see if it gives a syntax warning. I'm not familiar with Yii but find the files you've edited recently and run this:
php -f yourproject/somefile_ofyours.php
It will probably spit out an error like this:
PHP Parse error: syntax error, unexpected 'xxxxx' (T_STRING) in somefile_ofyours.php on line 27
Do you have a php errors log file set in php.ini? Does it contain anything?
Did you try forcing yii debug mode through php?
define( 'YII_DEBUG', true );
other top-of-the head ideas:
- enable html output of errors and warnings
- see in phpinfo that you're using the correct php.ini and that error reporting is indeeed what you set it to.
- check apache's error log
- what is the value of
$_SERVER['APPLICATION_ENV']
?
First of all...
you may check the rules, that the current user is allowed to view the error page
public function accessRules()
{
return array(array('allow',
'actions' => array('index', 'view', 'error'),
'users' => array('@')),
}
And also check.
public function actionError()
{
if($error=Yii::app()->errorHandler->error)
{
if(Yii::app()->request->isAjaxRequest)
echo $error['message'];
else
$this->render('error', $error);
}
}
When an error is forwarded to the CErrorHandler application component, it chooses an appropriate view to display the error.
This Link might help
protected function resolveErrorMessage($rule)
{
if($rule->message!==null)
return $rule->message;
elseif($this->message!==null)
return $this->message;
else
return Yii::t('yii','You are not authorized to perform this action.');
}
- Resolves the error message to be displayed.
- This method will check {@link message} and {@link CAccessRule::message} to see
- what error message should be displayed.
- @param CAccessRule $rule the access rule
- @return string the error message
Source: Link
Check your Error log files and post errors here. It may help to resolve your problems.
Also make sure to have below settings in PHP.ini
; Report All Errors
error_reporting = E_ALL
; Display Errors
display_errors = On
Registering a shutdown handler can also be of great benefit in these situations.
see
http://php.net/manual/en/function.register-shutdown-function.php
for more details,
By the by you can do some wild stuff with a good shutdown handler :)