定制 kiss-php/errors 二次开发

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

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

kiss-php/errors

Composer 安装命令:

composer require kiss-php/errors

包简介

Kiss errors manager for php.

README 文档

README

Kiss errors manager for PHP.

Install

Requires PHP 7.2 or newer.

composer require kiss-php/errors

Flow

Callbacks do not decide if the program continues.

KISS-PHP Errors follows PHP behavior:

  • Warnings, notices, deprecations, and strict errors continue after the callback.
  • Errors, parse errors, recoverable errors, and exceptions stop after the callback.
  • If there is no callback for an error type, PHP handles it with its default behavior.

Every callback receives an ErrorInfo object. You can also receive $message, $file, $line, and $level.

ALL

ALL::callback registers the same callback for every error type.

It receives the error type first.

<?php
require 'vendor/autoload.php';

use Kiss\Errors\ALL;

ALL::callback(function (string $type, $error, $message, $file, $line, $level) {
    echo '[' . $type . '] ' . $message . ' in ' . $file . ':' . $line;
});

WARNING

<?php
require 'vendor/autoload.php';

use Kiss\Errors\WARNING;

WARNING::callback(function ($error, $message, $file, $line, $level) {
    echo 'Warning: ' . $message . ' in ' . $file . ':' . $line;
});

fopen('missing-file.txt', 'r');

Warnings continue after the callback.

NOTICE

<?php
require 'vendor/autoload.php';

use Kiss\Errors\NOTICE;

NOTICE::callback(function ($error, $message, $file, $line, $level) {
    echo 'Notice: ' . $message . ' in ' . $file . ':' . $line;
});

Notices continue after the callback.

ERROR

<?php
require 'vendor/autoload.php';

use Kiss\Errors\ERROR;

ERROR::callback(function ($error, $message, $file, $line, $level) {
    echo 'Error: ' . $message . ' in ' . $file . ':' . $line;
});

Errors stop after the callback.

DEPRECATED

<?php
require 'vendor/autoload.php';

use Kiss\Errors\DEPRECATED;

DEPRECATED::callback(function ($error, $message, $file, $line, $level) {
    echo 'Deprecated: ' . $message . ' in ' . $file . ':' . $line;
});

Deprecations continue after the callback.

STRICT

<?php
require 'vendor/autoload.php';

use Kiss\Errors\STRICT;

STRICT::callback(function ($error, $message, $file, $line, $level) {
    echo 'Strict: ' . $message . ' in ' . $file . ':' . $line;
});

Strict errors continue after the callback.

RECOVERABLE

<?php
require 'vendor/autoload.php';

use Kiss\Errors\RECOVERABLE;

RECOVERABLE::callback(function ($error, $message, $file, $line, $level) {
    echo 'Recoverable error: ' . $message . ' in ' . $file . ':' . $line;
});

Recoverable errors stop after the callback.

PARSE_ERROR

<?php
require 'vendor/autoload.php';

use Kiss\Errors\PARSE_ERROR;

PARSE_ERROR::callback(function ($error, $message, $file, $line, $level) {
    echo 'Parse error: ' . $message . ' in ' . $file . ':' . $line;
});

Parse errors stop after the callback when PHP can report them during shutdown.

EXCEPTION

<?php
require 'vendor/autoload.php';

use Kiss\Errors\EXCEPTION;

EXCEPTION::callback(function ($error, $message, $file, $line, $level) {
    echo 'Exception: ' . $message . ' in ' . $file . ':' . $line;
});

$result = 24 / 0;

Exceptions stop after the callback.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固