viharm/php-khelper

PHP 库 Kint (http://kint-php.github.io/kint/) 的配套库

v1.4.1 2018-09-15 08:27 UTC

This package is auto-updated.

Last update: 2024-09-15 21:14:26 UTC


README

phpKhelper

版本1.4.1
下载https://gitlab.com/viharm/phpKhelper/tags
仓库https://gitlab.com/viharm/phpKhelper.git
问题https://gitlab.com/viharm/phpKhelper/issues
许可证BSD (3-clause)
语言PHP

phpKhelper 是与 Kint (http://kint-php.github.io/kint/) 配套使用的 PHP 库

安装

先决条件

文件 phpKhelper.lib.inc.phpKint 库的启动器。

Kint 是必需的 (http://kint-php.github.io/kint/),以及其依赖项

下载

下载调试模块。

存档

从本页顶部提供的下载链接下载最新版本的存档。

克隆仓库

将仓库克隆到所需位置;请记住递归地拉取子模块

git clone --recurse-submodules \
https://gitlab.com/viharm/phpKhelper.git

这确保了 Kint 也被下载。

部署

您应该有一个如下所示的目录结构

  • <YOURINCLUDEPATH>/phpKhelper/README.md
  • <YOURINCLUDEPATH>/phpKhelper/LICENSE
  • <YOURINCLUDEPATH>/phpKhelper/VERSION
  • <YOURINCLUDEPATH>/phpKhelper/phpKhelper.lib.inc.php
  • <YOURINCLUDEPATH>/phpKhelper/kint.php

配置

只需在您的代码中包含调试脚本。如果您的包含路径在子目录 Lib 中,则可以使用以下代码包含该目录中以 .inc.php 结尾的所有文件。

  $sr_Filename = '' ;
  foreach (
    glob ( 
      dirname(__FILE__) . DIRECTORY_SEPARATOR .
      'Lib' .  DIRECTORY_SEPARATOR .
      '*.inc.php'
    ) as $sr_Filename
  ) {
    include_once(realpath($sr_Filename)) ;
  }

用与应用程序环境相关/适当的值替换上述值。

用法

只需将您希望传递的变量传递给 phpKhelper

fn_Debug ( 'Some message describing the output' , $VariableToDebug ) ;

这仅将变量传递给 Kint

如果这是唯一所需的功能,则不需要 phpKhelper,并建议直接使用 Kint

可以通过将布尔值 $GLOBALS['bl_DebugSwitch'] 设置为 TRUE 来启用调试。

$GLOBALS['bl_DebugSwitch'] = TRUE ;

其他功能

已包含一些其他功能。

混淆

如果您的用户必须向您发送调试输出,则这可能会通过不让他们手动删除敏感信息来提供帮助。

可以在字符串变量或数组中的字符串项上执行混淆。

字符串

通过传递第三个非空参数混淆字符串

fn_Debug ( 'Some message describing the output' , $StringToDebug , 'AnyNonNullVariable' ) ;

这可以是任何东西,甚至是空字符串。

数组中的字符串

如果敏感数据在数组中,则只需按常规传递数组,然后传递要混淆其值的键名。

键名比较目前是区分大小写的。

单个键值

如果需要对单个键的所有出现值进行混淆,则第三个参数应为包含确切键名的字符串。

例如,对于以下数组

$ArrayToDebug = array (
  'username' => 'john' ,
  'password' => 'secret'
) ;

... 以下调用调试将混淆键 password 的值 (secret)。

fn_Debug ( 'Some message describing the output' , $ArrayToDebug , 'password' ) ;
多个键值

如果需要对多个键的所有出现值进行混淆,则第三个参数应为包含确切键名的非关联数组的字符串。

例如,对于以下数组

$ArrayToDebug = array (
  'username' => 'john' ,
  'password' => 'secret' ,
  'proxy'    => array (
    'proxyhost' => 'localhost' ,
    'proxyuser' => 'usernameforproxy' ,
    'proxypw'   => 'passwordforproxy'
  )
) ;

... 以下调用调试将混淆键 password 的值 (secret) 以及键 proxypw 的值 (passwordforproxy)。

fn_Debug ( 'Some message describing the output' , $ArrayToDebug , array('password','proxpw') ) ;

调试覆盖

如果全局调试被禁用($GLOBALS['bl_DebugSwitch'] = FALSE;),则第四个参数可以覆盖此设置,以便仅调试脚本中的特定部分。

fn_Debug ( 'Some message describing the output' , $VariableToDebug , NULL , TRUE ) ;

由于这是本地控制的,请记住禁用它,因为它会覆盖全局设置,因此后者对此将没有影响。

回退调试

一些框架可能会抑制Kint的输出(目前为止我还没有发现任何)。

在这种情况下,第五个参数可以使调试输出显示为PHP错误。

fn_Debug ( 'Some message describing the output' , $StringToDebug , NULL , NULL , TRUE ) ;

目前这仅适用于字符串变量。

已知限制

参见

支持

有关问题、查询、建议和评论,请使用本页顶部提供的链接创建问题。

贡献

请随时克隆/分叉并通过拉取请求进行贡献。也欢迎捐赠,只需按照上述方式提出问题即可。

请联系我们获取更多信息。

开发环境

开发于...

  • Debian Wheezy
  • Debian Jessie
  • Apache 2.2
  • Apache 2.4
  • PHP 5.4
  • PHP 5.5
  • PHP 5.6
  • Kint(截至2015-06-15)
  • Kint 2.1.2

许可证

许可协议为修改后的BSD(3条款)许可证。

许可证副本可在...

参考

Kint

Kint调试库(http://kint-php.github.io/kint/)。许可协议为MIT许可证

版权(c)2013 Jonathan Vollebregt(jnvsor at gmail dot com),Rokas Šleinius(raveren at gmail dot com)

鸣谢

Codiad

Codiad基于Web的IDE(https://github.com/Codiad/Codiad)。许可协议为MIT风格许可证。

版权(c)Codiad & Kent Safranski(codiad.com)

CodeGit

CodeGitCodiadGit插件(https://github.com/Andr3as/Codiad-CodeGit),使用MIT风格许可证。

版权(c)Andr3as andranode@gmail.com

Ungit

UngitGit的客户端(https://github.com/FredrikNoren/ungit),使用MIT许可证。

版权(C)Fredrik Norén

GitLab

GitLab代码仓库(gitlab.com)托管。