2015-03-02 55 views
0

我有xdebug安裝並運行在Ubuntu 14.10筆記本電腦使用Sublimetext 3正在開發。我的問題是使用@符號被xdebug分析而被抑制的錯誤。所以在我的整齊的MVC架構的任何自動加載機意味着我不得不重複按run快捷鍵最終是否通過或者沒有我的變化。非常刺激。更何況,我沒有scream啓用。在我phpinfo()scream搜索只生產xdebug.scream = OffXdebug的忽略錯誤抑制 - 尖叫沒有安裝

所以......在我的自動加載以下將觸發與Xdebug的警告。

@include $class . ".php"; 

我一定要明確告訴xdebug不要忽略錯誤?有沒有辦法對我來說,編程狀態,我想@include(警告通過了XDebug,但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/", 
     } 
    } 
} 
+0

奇怪,我用相當多的默認設置,和Xdebug沒有做任何事情 - 甚至沒有例外,除非我設置一個斷點......它可能是你的IDE設置,而不是XDebug的。 – calamari 2015-03-02 21:11:58

+0

可能很容易。將添加我的IDE設置爲xdebug – 2015-03-03 21:20:55

回答

0

我沒有崇高的文字,我是一個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 Input { 
    private $_input; 

    public function __construct(array $data) { 
     $this->_input= $data; 
    } 
    public function get($name) { 
     return isset($this->_input[$name]) ? $this->_input[$name] : null; 
    } 
} 

這樣做不僅使您不必壓制的錯誤,反而使得你的代碼更加靈活 - 至少提 - 能夠成爲如果Input被注入,則通過單元測試運行。

$data = new Input($_POST); 
$var = $data->get('name'); 
+0

我只有'致命錯誤'未註釋在我的設置。但我希望看到不被壓制的警告,並忽略 – 2015-03-04 15:54:00

+0

@Coombesy的警告,並在問題上更新了我的回答。 – calamari 2015-03-06 18:55:30