donquixote/nicetrace 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

donquixote/nicetrace

Composer 安装命令:

composer require donquixote/nicetrace

包简介

Library to make human-friendly PHP backtrace arrays.

README 文档

README

PHP library to generate a human-friendly backtrace array.

Inspired from ddebug_backtrace() in the Devel module for Drupal.

The structure of the nicetrace can be seen in nicetrace.php

Development status

This library is quite fresh, and I am still ironing out API details, that is, names of interfaces, method signatures, etc.
You are welcome to participate.

Features

The main design goal is a backtrace array structure that looks nice in recursive array display tools, such as Krumo, or possibly Ladybug.

  • Indices of trace items enhanced with function / method names.
  • Indices for arguments enhanced with parameter names (based on reflection).
  • Indices of trace items reversed, so that the index reflects the depth in the call tree.
  • Arguments inlined, so the array becomes flatter. E.g.
    $backtrace[5]['args'][0] = .. becomes
    $nicetrace[' 8: foo()']['args[0]: $x'] = ...
  • Filename and line number from trace item one level deeper, instead of the "called from".
  • File paths shortened, if known base paths are specified.
  • File basename and line number combined into one array key. E.g.
    $backtrace[5]['file'] = '/../src/MyNamespace/MyFile.php'; $backtrace[5]['line'] = 97; becomes
    $nicetrace[' 8: foo()']['MyClass.php: 97'] = 'src/MyNamespace/MyClass.php';

Basic usage

use Donquixote\Nicetrace\Util\NicetraceUtil;

$backtrace = debug_backtrace();
$nicetrace = NicetraceUtil::backtraceGetNicetrace($backtrace);

// Choose your favourite recursive function/method for recursive printing.
print_r($nicetrace);

Advanced usage

The library allows to create and compose custom BacktraceToNicetrace handlers.

It is recommended to use the fluent interface provided by the Builder class.

use Donquixote\Nicetrace\BacktraceToNicetrace\BacktraceToNicetraceBuilder;

$backtrace = debug_backtrace();
$backtraceToNicetrace = BacktraceToNicetraceBuilder::start()
  ->withClasslessKey()
  ->create();
$nicetrace = NicetraceUtil::backtraceGetNicetrace($backtrace);

// Choose your favourite recursive function/method for recursive printing.
print_r($nicetrace);

The test case gives some examples.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-03-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固