jun1019

一般在yaf项目调试的时候,如果代码有错误,页面只会响应500错误,但看不到哪里报了什么错误,通过开启yaf的一个配置可以将错误信息显示在页面上。

打开项目的index.php入口文件,在开头加入如下代码:

ini_set(\'display_errors\', 1);
error_reporting(E_ALL);

 

比如我的index.php入口文件内容如下:

<?php
ini_set(\'display_errors\', 1);
error_reporting(E_ALL);

define("APP_ROOT", realpath(dirname(__FILE__).\'/..\'));
define("APP_ENV", getenv(\'APP_ENV\') ? getenv(\'APP_ENV\') : \'product\');
define("DATA_PATH", APP_ROOT.\'/data\');

set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APP_ROOT . \'/vendor\'),
    get_include_path(),
)));

$app = new Yaf_Application(APP_ROOT . "/conf/application.ini");
$app->bootstrap()->run();

 

 我故意配置一个错误的数据库信息,在页面也会打印出错误信息:

 

如果没有开启上面的配置,页面将会展示500错误,而看不到具体的错误信息:

 

分类:

技术点:

相关文章:

  • 2021-12-12
  • 2021-12-12
  • 2021-12-12
  • 2021-12-12
  • 2022-01-20
  • 2021-06-16
  • 2021-09-26
猜你喜欢
  • 2022-02-15
  • 2021-07-30
  • 2021-06-21
  • 2021-12-17
  • 2021-06-18
  • 2021-11-18
  • 2022-12-23
相关资源
相似解决方案