PHP code example of php-errors / php-errors

1. Go to this page and download the library: Download php-errors/php-errors library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

php-errors / php-errors example snippets


$baseDir = dirname(__DIR__);
PHPErrors::enable(E_ALL, true);

//以下代码可选,用来设置日志记录器(推荐这么做)
$logger = new \Monolog\Logger("test");
$logger->pushHandler(new \Monolog\Handler\StreamHandler(__DIR__."/test.log"));
$errorHandler->setLogger($logger);
bash
display_errors = Off
display_startup_errors = Off
log_errors = On
error_log = 错误日志记录位置(绝对路径,也可以设置为 syslog,将日志打印到系统日志中)
error_reporting = E_ALL & E_STRICT

//php-fpm 环境下还应该设置 php-fpm 的配置,如下:通常位于 /path/to/fpm/pool.d/www.conf
catch_workers_output = yes
bash
{
    "hp-errors/php-errors": "~1.0"
    }
}