webservco/error
最新稳定版本:v1.0.0
Composer 安装命令:
composer require webservco/error
包简介
A PHP component/library.
关键字:
README 文档
README
A PHP component/library.
Custom application error handling.
Usage
Implement interfaces:
ErrorHandlerInterface
interface ErrorHandlerInterface { public function handle( // The first parameter, errno, will be passed the level of the error raised, as an integer. int $errno, // The second parameter, errstr, will be passed the error message, as a string. string $errstr, // If the callback accepts a third parameter, errfile, // it will be passed the filename that the error was raised in, as a string. string $errfile, // If the callback accepts a fourth parameter, errline, // it will be passed the line number where the error was raised, as an integer. int $errline, // $errcontext removed in PHP 8 ): bool; }
ErrorHandlingServiceFactoryInterface
interface ErrorHandlingServiceFactoryInterface { public function createErrorHandlingService(): ErrorHandlingServiceInterface; }
ErrorHandlingServiceInterface
interface ErrorHandlingServiceInterface { public function handlePreExecutionErrors(): bool; public function initialize(): bool; public function restore(): bool; }
Example implementation
A simple handling service using a strict error handler (throws exception for any error) is provided.
// Create service. $errorHandlingServiceFactory = new DefaultErrorHandlingServiceFactory(); $errorHandlingService = $errorHandlingServiceFactory->createErrorHandlingService(); // In application bootstrap: $errorHandlingService->initialize(); $errorHandlingService->handlePreExecutionErrors(); // Application run. // In application shutdown: $errorHandlingService->restore();
统计信息
- 总下载量: 407
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-02