Debugging

Debugging tools for the development of Webasyst framework-based software

Contents...

Debugging tools are available both for PHP and for Smarty code.

PHP code debugging

Debugging of Smarty templates code

function wa_dump ($var_1 [, $var_2, ..., $var_n])

Outputs to browser all passed parameters’ values and terminates the execution of PHP code. You can pass as many parameters as you need.

Parameters

Example

$var_1 = 'foo';
$var_2 = 42;
$var_3 = array(1, 2, 3);

wa_dump($var_1, $var_2);
wa_dump($var_3);

Result

'foo'

42

// The value of $var_3 will not be output because the execution of PHP code was terminated by previous call of wa_dump().

function wa_dumpс ($var_1 [, $var_2, ..., $var_n])

Outputs to browser the values of all passed parameters without terminating the execution of PHP code. You can pass as many parameters as you need.

Parameters

Example

$var_1 = 'foo';
$var_2 = 42;
$var_3 = array(1, 2, 3);

wa_dump($var_1, $var_2);
wa_dump($var_3);

Result

'foo'

42

// Value of $var_3 has been output because the execution of PHP code is NOT terminated by calls of wa_dumpc().
array(
    0 => 1,
    1 => 2,
    2 => 3,
)

public static function waLog::dump ($var_1 [, $var_2, ..., $var_n, $file = 'dump.log'])

Saves values to a log file. You can pass as many parameters as you need. The last parameter can be a file name if you need to use a name different from the default one dump.log.

It is convenient to view the contents of log files using the “Logs” app.

Parameters

Example

$var_1 = 'foo';
$var_2 = 42;
$var_3 = array(1, 2, 3);

waLog::dump($var_1, $var_2, $var_3);

Result

// Values will be saved to log file wa-log/dump.log.
'foo'

42

array(
    0 => 1,
    1 => 2,
    2 => 3,
)

public static function waLog::log ($var, $file = 'error.log')

Saves a value to a log file by casting it to string type.

It is convenient to view the contents of log files using the “Logs” app.

Parameters

Example

$var_1 = 'foo';
$var_2 = 42;

waLog::log($var_1);
waLog::log($var_2);

Result

// Values will be saved to file wa-log/error.log,
// each value for one call of waLog::log().
'foo'

42

Example

// Saving of several values to a log file
$var_1 = 'foo';
$var_2 = 42;
$var_3 = array(1, 2, 3);

waLog::log(json_encode(compact('var_1', 'var_2', 'var_3')));

Result

// Values will be saved to file wa-log/error.log.
{"var_1":"foo","var_2":42,"var_3":[1,2,3]}

{debug}

Opens Smarty debugging console.

Example

{debug}

{wa_tpl_vars}

Shows the list of template variables available in a file.

Example

{wa_tpl_vars}

Result

array(
    'SCRIPT_NAME' => '/index.php',
    'wa_url' => '/',
    'wa_static_url' => waCdn object {
        *cdn_list => array()
        *url => '/'
    },
    'wa_backend_url' => '/webasyst/',
    'wa_app' => 'myapp',
    'wa_app_url' => '/webasyst/myapp/',
    'wa_app_static_url' => waCdn object {
        *cdn_list => array()
        *url => '/webasyst/myapp/'
    },
    'wa_real_app_static_url' => '/wa-apps/myapp/',
    'wa' => waViewHelper object { ** skipped ** },
    'smarty' => NULL,
)

{wa_dump($var_1 [, $var_2, ..., $var_n])}
{$var|wa_dump}

Outputs values to browser and terminates execution of template code.

Example

{$var_1 = 'foo'}
{$var_2 = 42}

// You can output several values to once.
{wa_dump($var_1, $var_2)}

Result

'foo'

42

Example

{$var_1 = 'foo'}
{wa_dump($var_1)}

{wa_dump($var_2)}
{$var_2 = 42}

Result

'foo'

// The value of $var_2 will not be output because the execution of template code is terminated by previous call of wa_dump().

Example

{$var = 'foo'}

// You can output only one value when using the function as a modifier.
{$var|wa_dump}

Result

'foo'

{wa_dumpc($var_1 [, $var_2, ..., $var_n])}
{$var|wa_dumpc}

Outputs values to browser without terminating execution of template code.

Example

{$var_1 = 'foo'}
{$var_2 = 42}

// You can output several values to once.
{wa_dumpc($var_1, $var_2)}

Result

'foo'

42

Example

{$var_1 = 'foo'}
{wa_dumpc($var_1)}

{$var_2 = 42}
{wa_dumpc($var_2)}

Result

'foo'

// You can output several values after each other because the execution of template code is NOT terminated by previous calls of wa_dumpc().
42

Example

{$var = 'foo'}

// You can output only one value when using the function as a modifier.
{$var|wa_dump}

Result

'foo'