How to print the current call stack, function arguments and local variables?

7 years ago

David Grudl
Nette Core | 6827
+
+1
-

How to stop program execution and print current function, its arguments, call stack and local variables?

We need to activate Debugger in strict mode:

Debugger::$strictMode = TRUE
Debugger::enable();

(or using $configurator->enableDebugger()).

Than simply call $stop() in place you want to break program execution and show all information:

public function authenticate(array $credentials)
{
    list($username, $password) = $credentials;
    $row = $this->users->where('username', $username)->fetch();
    $stop();

    ...

Debugger will show you all information in eye-candy format.