xdebug 忽略错误抑制 - 未安装尖叫
xdebug ignoring error suppression - scream not installed
我已经安装了 xdebug
,并且正在 Ubuntu 14.10
笔记本电脑上使用 Sublimetext 3
进行开发。我的问题是使用 xdebug
解析的 @
符号抑制了错误。因此,在我整洁的 mvc 架构中的任何自动加载器都意味着我必须反复按 run
快捷键,以最终查看我的更改是否有效。非常烦人。更重要的是我没有启用 scream
。在我的 phpinfo()
中搜索 scream
只会产生 xdebug.scream = Off
.
所以...在我的自动加载器中,以下内容将触发 xdebug 警告。
@include $class . ".php";
我是否必须特别告诉 xdebug
不要忽略错误?有没有办法让我以编程方式声明我希望 xdebug 忽略 @include(
警告但触发 include(
警告?
感谢任何帮助。
SublimeText 3 xdebug settings
{
// For remote debugging to resolve the file locations
// it is required to configure the path mapping
// with the server path as key and local path as value.
//
// Make sure to use absolute path when defining server path,
// because Xdebug debugger engine does not return symbolic links.
//
// Example:
// "/absolute/path/to/file/on/server" : "/path/to/file/on/computer",
// "/var/www/htdocs/example/" : "C:/git/websites/example/"
"path_mapping": {
},
// Determine which URL to launch in the default web browser
// when starting/stopping a session.
"url": "",
// An IDE key is used to identify with debugger engine
// when Sublime Text will start or stop a debugging session.
//
// This package does not filter sessions by IDE key,
// it will accept any IDE key, also ones that do not match this configured IDE key.
// It is merely used when launching the default web browser with the configured URL.
"ide_key": "",
// Which port number Sublime Text should listen
// to connect with debugger engine.
"port": 9000,
// Show super globals in context view.
"super_globals": true,
// Maximum amount of array children
// and object's properties to return.
"max_children": 32,
// Maximum amount of
// variable data to initially retrieve.
"max_data": 1024,
// Maximum amount of nested levels to retrieve
// of array elements and object properties.
"max_depth": 1,
// Break at first line on session start, when debugger engine has connected.
"break_on_start": false,
// Break on exceptions, suspend execution
// when the exception name matches an entry in this list value.
"break_on_exception": [
// E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR
"Fatal error",
// E_RECOVERABLE_ERROR (since PHP 5.2.0)
"Catchable fatal error",
// E_WARNING, E_CORE_WARNING, E_COMPILE_WARNING, E_USER_WARNING
//"Warning"
],
// Always close debug windows and restore layout on session stop.
"close_on_stop": false,
// Do not show possible password values in context output.
"hide_password": false,
// Show in output parsed response instead of raw XML.
"pretty_output": false,
// Always launch browser on session start/stop.
// Note: This will only work if you have the 'url' setting configured.
"launch_browser": false,
// When launching browser on session stop do not execute script.
// By using parameter XDEBUG_SESSION_STOP_NO_EXEC instead of XDEBUG_SESSION_STOP.
"browser_no_execute": false,
// Do not use the debugging window layout.
"disable_layout": false,
// Window layout that is being used when debugging.
"debug_layout" : {
"cols": [0.0, 0.5, 1.0],
"rows": [0.0, 0.7, 1.0],
"cells": [[0, 0, 2, 1], [0, 1, 1, 2], [1, 1, 2, 2]]
},
// Group and index positions for debug views.
"breakpoint_group": 2,
"breakpoint_index": 1,
"context_group": 1,
"context_index": 0,
"stack_group": 2,
"stack_index": 0,
"watch_group": 1,
"watch_index": 1,
// Custom gutter icons for indicating current line or enabled/disabled breakpoints.
//
// Do not use same icon for following values, because Sublime Text is unable
// to use the same icon for different scopes, in case there are duplicate icons
// detected it will fall back to the corresponding icon in the package.
"breakpoint_enabled": "circle",
"breakpoint_disabled": "dot",
"breakpoint_current": "",
"current_line": "bookmark",
// Path to Python installation on your system.
// Which is being used to load missing modules.
//
// It is recommended to configure your Python path for Sublime Text 2
// especially on older UNIX systems, where some modules (xml.parsers.expat)
// might be missing and could improve performance of package.
//
// Example:
// "python_path" : "/usr/lib/python2.7"
"python_path" : "",
// Show detailed log information about communication
// between debugger engine and Sublime Text.
// Log can be found at Packages/User/Xdebug.log
"debug": false
}
以及我的项目特定设置(以防万一):
{
"folders":
[
{
"follow_symlinks": true,
"path": "/media/DATA/www/mysite.loc"
}
],
"settings": {
"xdebug": {
"url": "http://mysite.loc/",
}
}
}
我没有sublime text,我是PhpStorm的粉丝,所以我无法为你验证任何东西。但是,您应该能够添加不包括通知、警告等的 break_on_exception 配置,看看是否适合您:
http://kerryritter.com/quickstart-guide-to-debugging-php-in-sublime-text-3/
"break_on_exception": [
// E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR
"Fatal error",
// E_RECOVERABLE_ERROR (since PHP 5.2.0)
"Catchable fatal error",
// // E_WARNING, E_CORE_WARNING, E_COMPILE_WARNING, E_USER_WARNING
// "Warning",
// // E_PARSE
// "Parse error",
// // E_NOTICE, E_USER_NOTICE
// "Notice",
// // E_STRICT
// "Strict standards",
// // E_DEPRECATED, E_USER_DEPRECATED (since PHP 5.3.0)
// "Deprecated",
// // 0
// "Xdebug",
// // default
// "Unknown error"
],
[更新 2015-03-06]
如果您的 IDE 甚至因被抑制的错误而中断,那么我怀疑这是一个选择。但是,我的建议是让它不要因任何错误而中断,因为您可以很容易地在错误日志中看到带有尾巴的错误,而且我认为被抑制的错误不会出现在那里。但是,这对您来说是个问题,这听起来像是您在对很多错误使用错误抑制……只是我的两分钱,但情况永远不应该如此。
http://www.sitepoint.com/why-suppressing-notices-is-wrong/
即使抑制错误也会降低应用程序的性能...因此,如果您使用抑制来避免测试未定义的索引等,例如
$var = @$_POST['name']
只是为了避免这样做:
$var = isset($_POST['name']) ? $_POST['name'] : null;
那么,你应该重新考虑你的所作所为,停止使用压制。例如,最好写一个包装器 class:
class Input {
private $_input;
public function __construct( array $data ) {
$this->_input= $data;
}
public function get( $name ) {
return isset($this->_input[$name]) ? $this->_input[$name] : null;
}
}
这样做不仅可以让您不必抑制错误,而且可以使您的代码更加灵活——尤其值得一提的是——如果注入了输入,则能够通过单元测试 运行。
$data = new Input($_POST);
$var = $data->get('name');
我已经安装了 xdebug
,并且正在 Ubuntu 14.10
笔记本电脑上使用 Sublimetext 3
进行开发。我的问题是使用 xdebug
解析的 @
符号抑制了错误。因此,在我整洁的 mvc 架构中的任何自动加载器都意味着我必须反复按 run
快捷键,以最终查看我的更改是否有效。非常烦人。更重要的是我没有启用 scream
。在我的 phpinfo()
中搜索 scream
只会产生 xdebug.scream = Off
.
所以...在我的自动加载器中,以下内容将触发 xdebug 警告。
@include $class . ".php";
我是否必须特别告诉 xdebug
不要忽略错误?有没有办法让我以编程方式声明我希望 xdebug 忽略 @include(
警告但触发 include(
警告?
感谢任何帮助。
SublimeText 3 xdebug settings
{
// For remote debugging to resolve the file locations
// it is required to configure the path mapping
// with the server path as key and local path as value.
//
// Make sure to use absolute path when defining server path,
// because Xdebug debugger engine does not return symbolic links.
//
// Example:
// "/absolute/path/to/file/on/server" : "/path/to/file/on/computer",
// "/var/www/htdocs/example/" : "C:/git/websites/example/"
"path_mapping": {
},
// Determine which URL to launch in the default web browser
// when starting/stopping a session.
"url": "",
// An IDE key is used to identify with debugger engine
// when Sublime Text will start or stop a debugging session.
//
// This package does not filter sessions by IDE key,
// it will accept any IDE key, also ones that do not match this configured IDE key.
// It is merely used when launching the default web browser with the configured URL.
"ide_key": "",
// Which port number Sublime Text should listen
// to connect with debugger engine.
"port": 9000,
// Show super globals in context view.
"super_globals": true,
// Maximum amount of array children
// and object's properties to return.
"max_children": 32,
// Maximum amount of
// variable data to initially retrieve.
"max_data": 1024,
// Maximum amount of nested levels to retrieve
// of array elements and object properties.
"max_depth": 1,
// Break at first line on session start, when debugger engine has connected.
"break_on_start": false,
// Break on exceptions, suspend execution
// when the exception name matches an entry in this list value.
"break_on_exception": [
// E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR
"Fatal error",
// E_RECOVERABLE_ERROR (since PHP 5.2.0)
"Catchable fatal error",
// E_WARNING, E_CORE_WARNING, E_COMPILE_WARNING, E_USER_WARNING
//"Warning"
],
// Always close debug windows and restore layout on session stop.
"close_on_stop": false,
// Do not show possible password values in context output.
"hide_password": false,
// Show in output parsed response instead of raw XML.
"pretty_output": false,
// Always launch browser on session start/stop.
// Note: This will only work if you have the 'url' setting configured.
"launch_browser": false,
// When launching browser on session stop do not execute script.
// By using parameter XDEBUG_SESSION_STOP_NO_EXEC instead of XDEBUG_SESSION_STOP.
"browser_no_execute": false,
// Do not use the debugging window layout.
"disable_layout": false,
// Window layout that is being used when debugging.
"debug_layout" : {
"cols": [0.0, 0.5, 1.0],
"rows": [0.0, 0.7, 1.0],
"cells": [[0, 0, 2, 1], [0, 1, 1, 2], [1, 1, 2, 2]]
},
// Group and index positions for debug views.
"breakpoint_group": 2,
"breakpoint_index": 1,
"context_group": 1,
"context_index": 0,
"stack_group": 2,
"stack_index": 0,
"watch_group": 1,
"watch_index": 1,
// Custom gutter icons for indicating current line or enabled/disabled breakpoints.
//
// Do not use same icon for following values, because Sublime Text is unable
// to use the same icon for different scopes, in case there are duplicate icons
// detected it will fall back to the corresponding icon in the package.
"breakpoint_enabled": "circle",
"breakpoint_disabled": "dot",
"breakpoint_current": "",
"current_line": "bookmark",
// Path to Python installation on your system.
// Which is being used to load missing modules.
//
// It is recommended to configure your Python path for Sublime Text 2
// especially on older UNIX systems, where some modules (xml.parsers.expat)
// might be missing and could improve performance of package.
//
// Example:
// "python_path" : "/usr/lib/python2.7"
"python_path" : "",
// Show detailed log information about communication
// between debugger engine and Sublime Text.
// Log can be found at Packages/User/Xdebug.log
"debug": false
}
以及我的项目特定设置(以防万一):
{
"folders":
[
{
"follow_symlinks": true,
"path": "/media/DATA/www/mysite.loc"
}
],
"settings": {
"xdebug": {
"url": "http://mysite.loc/",
}
}
}
我没有sublime text,我是PhpStorm的粉丝,所以我无法为你验证任何东西。但是,您应该能够添加不包括通知、警告等的 break_on_exception 配置,看看是否适合您:
http://kerryritter.com/quickstart-guide-to-debugging-php-in-sublime-text-3/
"break_on_exception": [
// E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR
"Fatal error",
// E_RECOVERABLE_ERROR (since PHP 5.2.0)
"Catchable fatal error",
// // E_WARNING, E_CORE_WARNING, E_COMPILE_WARNING, E_USER_WARNING
// "Warning",
// // E_PARSE
// "Parse error",
// // E_NOTICE, E_USER_NOTICE
// "Notice",
// // E_STRICT
// "Strict standards",
// // E_DEPRECATED, E_USER_DEPRECATED (since PHP 5.3.0)
// "Deprecated",
// // 0
// "Xdebug",
// // default
// "Unknown error"
],
[更新 2015-03-06]
如果您的 IDE 甚至因被抑制的错误而中断,那么我怀疑这是一个选择。但是,我的建议是让它不要因任何错误而中断,因为您可以很容易地在错误日志中看到带有尾巴的错误,而且我认为被抑制的错误不会出现在那里。但是,这对您来说是个问题,这听起来像是您在对很多错误使用错误抑制……只是我的两分钱,但情况永远不应该如此。
http://www.sitepoint.com/why-suppressing-notices-is-wrong/
即使抑制错误也会降低应用程序的性能...因此,如果您使用抑制来避免测试未定义的索引等,例如
$var = @$_POST['name']
只是为了避免这样做:
$var = isset($_POST['name']) ? $_POST['name'] : null;
那么,你应该重新考虑你的所作所为,停止使用压制。例如,最好写一个包装器 class:
class Input {
private $_input;
public function __construct( array $data ) {
$this->_input= $data;
}
public function get( $name ) {
return isset($this->_input[$name]) ? $this->_input[$name] : null;
}
}
这样做不仅可以让您不必抑制错误,而且可以使您的代码更加灵活——尤其值得一提的是——如果注入了输入,则能够通过单元测试 运行。
$data = new Input($_POST);
$var = $data->get('name');