stopsopa / envext
基于symfony VarDumper组件的调试工具,用于在开发机上本地安装
v1.0.4
2016-10-25 22:55 UTC
Requires
- symfony/var-dumper: ^3.1
This package is auto-updated.
Last update: 2024-09-05 09:39:27 UTC
README
灵感
来自VarDumper组件文档的说明 链接
老天爷,为什么有这个库?
普通的dump()函数打印变量,但通常这还不够。执行函数的行号有时甚至更有用,尤其是当你通过在代码中放置多个dump()进行调试,后来又想全部删除它们时。
示例
使用方法
这个库提供了两个函数 "d()" 和 "dd()"
- 函数d()打印数据并通过die()终止脚本
- 函数dd()打印数据并允许脚本继续执行
不包含到项目中安装
sudo -i
cd /bin
composer require stopsopa/envext:dev-master
添加到php.ini(http和cli模式)(centos的/etc/php.ini)
auto_prepend_file = /bin/vendor/autoload.php
设置nginx(通常在/etc/nginx/sites-enabled/default.conf中)...
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index app.php;
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_param PHP_VALUE "auto_prepend_file = /bin/vendor/autoload.php";
}
..或者设置apache2
<Directory />
AllowOverride none
Require all denied
Php_value auto_prepend_file /bin/vendor/autoload.php
</Directory>
重启nginx/apache(或其他http服务器)
centos
/etc/init.d/nginx restart
sudo apachectl restart
ubuntu
sudo service nginx restart
sudo service apache2 restart
测试
命令行界面
echo '<?php dd("one");d("stop here");d("should t see this");' > test.php && php test.php && rm test.php
网络
echo '<?php dd("one");d("stop here");d("should t see this");' > test.php
...然后从网络调用,然后删除test.php