wikimedia/at-ease
Composer 安装命令:
composer require wikimedia/at-ease
包简介
Safe replacement to @ for suppressing warnings.
README 文档
README
at-ease
at-ease is a PHP library that provides a safe alternative to PHP's @ error control operator.
@ is broken when E_STRICT is enabled and it causes an unlogged,
unexplained error if there is a fatal, which is hard to support. The proper
method of handling errors is to actually handle the errors. For example, if
you are thinking of using an error suppression operator to suppress an invalid
array index warning, you should instead perform an isset() check on the
array index before trying to access it. When possible, always prevent PHP
errors rather than catching and handling them afterward. It makes the code
more understandable and avoids dealing with slow error suppression methods.
However, there are some cases where warnings are inevitable, even if you check
beforehand, like when accessing files. You can check that the file exists by
using file_exists() and is_readable(), but the file could have been
deleted by the time you go to read it. In that case, you can use this library
to suppress the warnings and prevent PHP from being noisy.
Usage
use Wikimedia\AtEase\AtEase; // Suppress warnings in a block of code: AtEase::suppressWarnings(); $content = file_get_contents( 'foobar.txt' ); AtEase::restoreWarnings(); // ..or in a callback function: AtEase::quietCall( 'file_get_contents', 'foobar.txt' );
Running tests
composer install --prefer-dist
composer test
History
This library was first introduced in MediaWiki 1.3 (r4261). It was split out of the MediaWiki codebase and published as an independent library during the MediaWiki 1.26 development cycle.
wikimedia/at-ease 适用场景与选型建议
wikimedia/at-ease 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19.14M 次下载、GitHub Stars 达 14, 最近一次更新时间为 2018 年 04 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 wikimedia/at-ease 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wikimedia/at-ease 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 19.14M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 15
- 点击次数: 24
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2018-04-17