承接 simplecomplex/inspect 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

simplecomplex/inspect

Composer 安装命令:

composer require simplecomplex/inspect

包简介

PHP and Javascript library for inspecting variables and stack traces.

README 文档

README

Get Inspect

// If dependency injection container exists.
$inspect = $container->get('inspect');
// Otherwise use maker.
$inspect = \SimpleComplex\Inspect\Inspect::getInstance();

Principal methods and options

(int) $options

depth: max object/array recursion; DEPTH_DEFAULT/TRACE_DEPTH_DEFAULT

(array) $options

  • (int) depth: max object/array recursion; DEPTH_DEFAULT/TRACE_DEPTH_DEFAULT
  • (int) limit: max trace frame; TRACE_LIMIT_DEFAULT
  • (int) code: error code, overrides exception code; none
  • (int) truncate: string truncation; TRUNCATE_DEFAULT
  • (arr) skip_keys: skip those object/array keys; none
  • (arr) needles: replace in strings; NEEDLES/NEEDLES_ESCAPE_HTML
  • (arr) replacers: replace in strings; REPLACERS/REPLACERS_ESCAPE_HTML
  • (bool) escape_html: replace in strings; ESCAPE_HTML
  • (int) output_max: replace in strings; OUTPUT_DEFAULT
  • (int) exectime_percent: replace in strings; EXEC_TIMEOUT_DEFAULT
  • (bool) rootdir_replace: replace root dir in strings; ROOT_DIR_REPLACE
  • (int) wrappers: number of wrapping functions/methods, to be hidden; zero

inspect($subject, $options = []): Inspector

Do variable inspection, unless arg $subject is a throwable; then trace.

$var = 'what is this?'; $xcptn = new \Exception('Doh');

// Inspect:
$inspect->inspect($var);
// Trace:
$inspect->inspect($xcptn);

variable($subject, $options = []): Inspector

Force variable inspection, even if subject is a throwable.

$inspect->variable($var);

trace($throwableOrNull, $options = []): Inspector

Trace exception or do back-trace.

// Trace exception:
$inspect->trace($xcptn);
// Do back-trace:
$inspect->trace(null);

Logging

The Inspector returned by inspect|variable|trace() is stringable. Pass it directly to a PSR logger:

$logger->debug('Darned ding' . "\n" . $inspect->variable($var));

Or use the Inspector's own chainable PSR logger-like method:

log($level = 'debug', $message = '', array $context = []): void

$inspect->variable($var)->log('debug', 'darned ding');

Javascript

(object) options

  • (string) message: content headline and options as string also interprets to message (except when 'protos'/'func_body')
  • (integer) depth: array|object recursion max (default 10, max 10)
  • (boolean) protos: analyze prototypal properties too
  • (boolean) func_body: print bodies of functions
  • (string) type: default 'inspect'/'inspect trace'
  • (string) severity: default 'debug'/'error'

To console:

window.inspect(u, options);
window.inspect.trace(er, options);

Description

Produces tidy and informative variable dumps and exception/back traces.
Tailormade and ready for logging - the inspect/variable/trace() methods return a stringable object.

Safe

The inspector and tracer guarantee not to fail. A simple PHP:var_dump() is prone to raise a PHP error if you dump a large or complex array like $GLOBALS, due to references (recursion).
Inspect limits it's recursion into sub arrays/objects. It also keeps track of how large an output it produces. And it finally makes sure that max execution time doesn't get exceeded.

Secure

Inspect hides the values of array/object buckets named 'pw', 'pass' and 'password'.
And values of other sensitives can be hidden using 'skip_keys' option.

PHP and Javascript

Inspect consists of a PHP library for serverside inspection and tracing, and a Javascript library for clientside ditto.
NB: The Javascript library has not been maintained since 2015.

Maturity

The library has existed in various forms since 2010. The core has been refined continuously whereas the wrapping has evolved from a rather oldschool OOP pattern over a solid but non-orthodox Drupal style, to well-behaved PSR/Composer patterns.

Used in - extended by - Drupal

The backbone of the Drupal Inspect module is SimpleComplex Inspect. The Drupal module (D7 as well as D8) extends Inspect to accomodate to the context - that is: uses Drupal's APIs and features when it makes sense.

MIT licensed

License and copyright. Explained.

Requirements

  • PHP >=8.1

simplecomplex/inspect 适用场景与选型建议

simplecomplex/inspect 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 169.4k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 07 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「dump」 「trace」 「developer」 「inspect」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 simplecomplex/inspect 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 simplecomplex/inspect 我们能提供哪些服务?
定制开发 / 二次开发

基于 simplecomplex/inspect 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-12