xdebug and 'Analyze Stacktrace'

Hello !
Hello!

I am using xdebug.
Sometimes I make mistakes and get a 'stack trace' of xdebug in the browser.

Can I use this in PhpStorm trace the error to track down?

Is it to 'Analyze Stacktrace' and 'xdebug' a tutorial?

Sincerely

Stephan

5 comments

Hello Stephan,

It depends on the stack trace format. 'Analyze Stactrace' feature supports any standard PHP stacktrace.

See how to use 'Analyze Stacktrace' with 'Xdebug':

1. Tools | Analyze Stacktrace:
analyze_stacktrace_action.png

2. Simply copy/paste the text of the stacktrace to the text pane:
analyze_stacktrace_dialog.png

Thank you for feedback!

0

Hello!

How can I produce with an external tool, a stack trace?
Can I produce a stack trace with PhpStorm?

For example:
I want to insert the code in PhpStorm in a command.
This command will generate a stack trace.
Is this possible?

Can I 'xdebug_print_function_stack ("My stack trace'); 'use?

Sorry for my bad English.

Yours sincerely,

Stephan

0

Hello !

Here my first test:

-------------------------------

<?php

class documentor{

    private $_variable;

    
    public function setzeVariable($parameter) {
        $this->_variable = $parameter;

        if($this->start($parameter) + $this->_test($parameter))
            $parameter = $this->_test($parameter);

        return $this->_variable;
    }


    public function start($__wert){

        $this->_variable += 5;

        xdebug_print_function_stack( 'my stack trace' );

        return $__wert;
    }

    private function _test($__wert){

        $this->_variable += 5;

        return $__wert;
    }

}

$docu = new documentor();
$parameter = $docu->setzeVariable(5);

--------------------------------------

And here the result:

test.jpg
Your sincerly

Stephan

0

Hello!

Here is my second test.
I have php generate the 'Exception' used a 'trace'.
In my daily work I use the design pattern 'MVC'.

Here is an example of the controller code.

------------------------------------------------
<?php

class documentor{
  
    private $_variable;

    public function setzeVariable($parameter) {
        $this->_variable = $parameter;

        if($this->start($parameter) + $this->_test($parameter))
            $parameter = $this->_test($parameter);

        return $this->_variable;
    }


    public function start($__wert){

        $this->_variable += 5;

        throw new Exception('test exception');

        return $__wert;
    }

    private function _test($__wert){

        $this->_variable += 5;

        return $__wert;
    }

}

try{
    $docu = new documentor();
    $parameter = $docu->setzeVariable(5);
}
catch(Exception $e){
    var_dump($e->getTraceAsString());
}

----------------------------------------
Here is the output of the trace.


trace.jpg
And here the Trace in PhpStorm.

trace1.jpg
You can see the trace of the program execution.
Calling the methods and content of variables methods.


If one has documented the API with the phpDocumentor
then you can quickly explore the design of a program.

Can be obtained by changing the php.ini file for more information?


Sorry for my bad english.

Yours sincerely,

Stephan

0

Stephan,

Have a look at frameworks like Yii, Kohana (and others) -- they do have their own implementation of error page where framework displays tons of information. If you look at that code you will see how they have implemented it (including method parameters, type and value of parameter etc etc). In short -- check Exception->getTrace() method (instead of getTraceAsString() ) so you can build your own stack.

0

Please sign in to leave a comment.