定制 twocoffeecups/php-error-handler 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

twocoffeecups/php-error-handler

最新稳定版本:0.0.1

Composer 安装命令:

composer require twocoffeecups/php-error-handler

包简介

A simple and easy php error handler.

README 文档

README

An easy-to-use PHP error handler that helps with code debugging and allows you to save logs.

Screenshot 2024-10-07 231526

Installation

Use this command:

composer require twocoffeecups/php-error-handler

Usage

Add the class \TwoCoffeCups\PHPErrorHandler\ErrorHandler() to the beginning of your index file:

<?php

require_once "../vendor/autoload.php";

// new ErrorHandler object
new \TwoCoffeCups\PHPErrorHandler\ErrorHandler();

// your code:
...

Log files

You can save the error log to a file by adding two optional parameters to the class declaration.

  • $saveLog: By default, it takes the value is false. To enable saving logs, set the value - true.
  • $pathToLogFile: By default, it takes the value is null. Add a string variable with the path to the folder containing the log file.

Usage example:

$saveLog = true;

// path to logs dir
$pathToLogFile = __DIR__ . "/logs";

// new ErrorHandler object
new \TwoCoffeCups\PHPErrorHandler\ErrorHandler(
    $saveLog,
    $pathToLogFile,
);

Debug

If you want to use the funds for debugging, add to the beginning of the script:

use TwoCoffeCups\PHPErrorHandler\Debugger\Debugger;

And use it in your code:

$str = "Some text";

// if you need the script not to shut down
Debugger::dump($str)

// if you need the script to shut down
Debugger::dd($str)

Known problems

  • If you have enabled the saving of log files and receive the "access error" message, please check that you have permission to write files to the specified folder.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-07