class Debug (View source)

Supports debugging and core error handling.

Attaches custom methods to the default error handling hooks in PHP. Currently, two levels of error are supported:

  • Notice
  • Warning
  • Error

Uncaught exceptions are currently passed to the debug reporter as standard PHP errors.

Errors handled by this class are passed along to SS_Log. For configuration information, see the SS_Log class documentation.

add support for user defined config: Debug::die_on_notice(true | false) better way of figuring out the error context to display in highlighted source

Properties

Methods

public static 
show($val, $showHeader = true)

Show the contents of val in a debug-friendly way.

public static 
array
caller()

Returns the caller for a specific method

public static 
endshow(mixed $val)

Close out the show dumper

public static 
dump(mixed $val)

Quick dump of a variable.

public static 
unknown
text(unknown_type $val)

??

public static 
message($message, $showHeader = true)

Show a debugging message

public static 
void
header(string $msg, string $prefix = null)

Send a debug message in an HTTP header. Only works if you are on Dev, and headers have not yet been sent.

public static 
log($message)

Log to a standard text file output.

public static 
loadErrorHandlers()

Load error handlers into environment.

public static 
noticeHandler($errno, $errstr, $errfile, $errline, $errcontext)

No description

public static 
warningHandler(unknown_type $errno, unknown_type $errstr, unknown_type $errfile, unknown_type $errline, unknown_type $errcontext)

Handle a non-fatal warning error thrown by PHP interpreter.

public static 
fatalHandler(unknown_type $errno, unknown_type $errstr, unknown_type $errfile, unknown_type $errline, unknown_type $errcontext)

Handle a fatal error, depending on the mode of the site (ie: Dev, Test, or Live).

public static 
string
friendlyError(int $statusCode = 500, string $friendlyErrorMessage = null, string $friendlyErrorDetail = null)

Render a user-facing error page, using the default HTML error template rendered by ErrorPage} if it exists. Doesn't use the standard {@link SS_HTTPResponse class the keep dependencies minimal.

public static 
create_debug_view()

Create an instance of an appropriate DebugView object.

public static 
showError(unknown_type $errno, unknown_type $errstr, unknown_type $errfile, unknown_type $errline, unknown_type $errcontext, $errtype)

Render a developer facing error page, showing the stack trace and details of the code where the error occured.

public static 
showLines(string $errfile, int $errline)

Utility method to render a snippet of PHP source code, from selected file and highlighting the given line number.

public static 
require_developer_login()

Check if the user has permissions to run URL debug tools, else redirect them to log in.

Details

static show($val, $showHeader = true)

Show the contents of val in a debug-friendly way.

Debug::show() is intended to be equivalent to dprintr()

Parameters

$val
$showHeader

static array caller()

Returns the caller for a specific method

Return Value

array

static endshow(mixed $val)

Close out the show dumper

Parameters

mixed $val

static dump(mixed $val)

Quick dump of a variable.

Parameters

mixed $val

static unknown text(unknown_type $val)

??

Parameters

unknown_type $val

Return Value

unknown

static message($message, $showHeader = true)

Show a debugging message

Parameters

$message
$showHeader

static void header(string $msg, string $prefix = null)

Send a debug message in an HTTP header. Only works if you are on Dev, and headers have not yet been sent.

Parameters

string $msg
string $prefix (optional)

Return Value

void

static log($message)

Log to a standard text file output.

Parameters

$message

string to output

static loadErrorHandlers()

Load error handlers into environment.

Caution: The error levels default to E_ALL is the site is in dev-mode (set in main.php).

static noticeHandler($errno, $errstr, $errfile, $errline, $errcontext)

No description

Parameters

$errno
$errstr
$errfile
$errline
$errcontext

static warningHandler(unknown_type $errno, unknown_type $errstr, unknown_type $errfile, unknown_type $errline, unknown_type $errcontext)

Handle a non-fatal warning error thrown by PHP interpreter.

Parameters

unknown_type $errno
unknown_type $errstr
unknown_type $errfile
unknown_type $errline
unknown_type $errcontext

static fatalHandler(unknown_type $errno, unknown_type $errstr, unknown_type $errfile, unknown_type $errline, unknown_type $errcontext)

Handle a fatal error, depending on the mode of the site (ie: Dev, Test, or Live).

Runtime execution dies immediately once the error is generated.

Parameters

unknown_type $errno
unknown_type $errstr
unknown_type $errfile
unknown_type $errline
unknown_type $errcontext

static string friendlyError(int $statusCode = 500, string $friendlyErrorMessage = null, string $friendlyErrorDetail = null)

Render a user-facing error page, using the default HTML error template rendered by ErrorPage} if it exists. Doesn't use the standard {@link SS_HTTPResponse class the keep dependencies minimal.

Parameters

int $statusCode

HTTP Status Code (Default: 500)

string $friendlyErrorMessage

User-focused error message. Should not contain code pointers or "tech-speak". Used in the HTTP Header and ajax responses.

string $friendlyErrorDetail

Detailed user-focused message. Is just used if no ErrorPage is found for this specific status code.

Return Value

string

HTML error message for non-ajax requests, plaintext for ajax-request.

static DebugView create_debug_view()

Create an instance of an appropriate DebugView object.

Return Value

DebugView

static showError(unknown_type $errno, unknown_type $errstr, unknown_type $errfile, unknown_type $errline, unknown_type $errcontext, $errtype)

Render a developer facing error page, showing the stack trace and details of the code where the error occured.

Parameters

unknown_type $errno
unknown_type $errstr
unknown_type $errfile
unknown_type $errline
unknown_type $errcontext
$errtype

static showLines(string $errfile, int $errline)

Utility method to render a snippet of PHP source code, from selected file and highlighting the given line number.

Parameters

string $errfile
int $errline

static require_developer_login()

Check if the user has permissions to run URL debug tools, else redirect them to log in.