白屏死亡 - PHP / Vagrant环境中没有显示错误(Yii) [英] White screen of death - no errors showing within PHP/Vagrant environment (Yii)

查看:149
本文介绍了白屏死亡 - PHP / Vagrant环境中没有显示错误(Yii)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能确定这个问题是否部分是由于流氓,但是我在一个运行Unix的Vagrant框中安装了Yii 1.x。



我是尝试强制一个简单的PHP错误,如控制器中的一个缺少的分号,即使我100%确定我有一个创建的错误,我没有看到标准的Yii错误页面与堆栈跟踪。这样以前一直工作过,虽然似乎最近已经以这种方式停止了这种工作。



奇怪的是 - Yii正在脚本底部输出数据库查询(这是打算的,但我不明白为什么Yii只显示DB查询。



我的个人配置如下所示:(仅显示其中的一部分) p>

我已经尝试了下面的代码并检查日志,但没有喜悦

  ini_set('display_errors',true); 
error_reporting(E_ALL);

任何人建议任何想法...

  return array(
'yiiDebug'=> true,
' yiiTraceLevel'=> 6,
.....


'components'=>数组(
'log'=>数组(
'class'=>'CLogRouter',
'routes'=>数组(
'web'=>数组(
'class'=>'CWebLogRoute'
'levels' =''profile,trace,info,error,warning,application',// profile,trace,info,error,warning,application
'showInFireBug'=> false
),
'file'=>数组(
'class'=>'CFileLogRoute',
'levels'=>'error,warning,watch',// error,warning,watch
'categories'=> ;'系统*',
),
数组(
'class'=>'CProfileLogRoute',
'levels'=>'错误,信息,配置文件',//错误,警告,跟踪,信息,配置文件
),
),
),
),

所以例如...在我的一个控制器我有以下代码:

  public function actionDelete($ id)
{
$ model = $ this-> loadModel($ id);
5e55 //在目的地添加错误
}

我会期待关于没有位置的5e55的第二行的错误,但是不是收到错误,我看到的只是一个白屏(加上显示所有查询的Yii应用程序日志等) - 如果我删除了yii配置东西来输出查询我得到一个100%的白色/空白屏幕。



我已经尝试添加各种各样的东西到index.php bootstrap文件,但没有任何快乐,我的配置看起来相对正常但我不明白为什么错误报告给浏览器或我的日志。

解决方案

你做了正确的通过设置

  ini_set('display_errors',true); 
error_reporting(E_ALL);

...但有几个原因可能无法实际生效。



1)错误报告可能会在脚本中的稍后再次被关闭。因为这些设置基本上只是全局变量,任何人都可以设置它们,大多数框架都被禁用。根据您的代码包含在其中的其他内容可能会被称为display_errors - false。



2)更改设置可以在运行时禁用。您的环境可能有一些类似php_admin_flag指令来停止display_errors被打开。



如果您能够获得输出,请尝试运行此命令转储所有的状态ini设置:

  var_dump(ini_get_all()); 

但是我认为可能会发生是你有一个小的语法错误在您自己的文件之一,解释器完全放弃该代码。它永远不会执行,所以你的display_errors设置甚至没有运行。



正如其他人建议看看你的错误日志可能会告诉你发生了什么。 / p>

另一个奇怪但有用的方法是在命令行中尝试执行文件,看看是否给出语法警告。我不熟悉Yii,但找到你最近编辑的文件,并运行这个:

  php -f yourproject / somefile_ofyours .php 

可能会出现如下错误:

  PHP解析错误:语法错误,意外的'xxxxx'(T_STRING)在somefile_ofyours.php第27行


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

这篇关于白屏死亡 - PHP / Vagrant环境中没有显示错误(Yii)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆