jewei / dumpdump
PHP var_dump 如此高效。
1.0.1
2016-03-18 09:21 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2024-09-11 19:15:34 UTC
README
将 PHP var dump 输出到文件。
有时候你无法使用 echo'<pre>';var_dump($var);die; 将调试信息发送到浏览器窗口。特别是在 AJAX 请求或 cron 运行期间。在这种情况下,你可以将调试信息发送到单独的通道,即普通文件。想象一下,现在你可以使用控制台来 tail -f debug.txt。
这并不是一个完整的调试器。如果你在寻找一个,你可能想看看这些:
安装
通过 Composer 全局安装。
composer global require jewei/dumpdump
添加到 php.ini 以使 PHP 能够自动加载。
auto_prepend_file = ${HOME}/.composer/vendor/autoload.php
使用 Git 仓库。
克隆此仓库并 require '/path/to/src/Dump.php';。
使用方法
<?php
// /path/to/your/file.php
// If not installed globally, load it locally.
require __DIR__.'/vendor/autoload.php';
use Jewei\DumpDump\Dump;
// Var dump like a boss.
Dump::dump('hello', 'make this id 789');
// Dump using function.
$var = array('some', 'data', 'you', 'want', 'to', 'see');
dumpdump($var, 'this is optional id of coz');
生成输出
[make this id 789]
Fri, 18 Mar 2016 16:16:53 +0800
/path/to/your/file.php dump:10
--------------------------------------------------------------------------------
string 'hello' (length=5)
--------------------------------------------------------------------------------
[this is optional id of coz]
Fri, 18 Mar 2016 16:16:53 +0800
/path/to/your/file.php dumpdump:14
--------------------------------------------------------------------------------
array (size=6)
0 => string 'some' (length=4)
1 => string 'data' (length=4)
2 => string 'you' (length=3)
3 => string 'want' (length=4)
4 => string 'to' (length=2)
5 => string 'see' (length=3)
--------------------------------------------------------------------------------
配置
将 config.json.dist 复制到 config.json。
{
"file_name":"debug.txt",
"display_time":true,
"time_format":"r"
}
编辑配置值并保存。
filename - The file path where the output goes to.
display_time - Boolean show or no.
time_format - Accept PHP date() format.