Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

starting xdebug inside code?

I know these ways of starting Xdebug:

?XDEBUG_SESSION_START=name in url

xdebug.remote_autostart=On in php.ini

-dxdebug.remote_autostart=On as parameter to the PHP binary call

but I do not know how to start xdebug inside code, is there any function like xdebug_start() and xdebug_stop() ?

like image 325
rsk82 Avatar asked Nov 13 '11 21:11

rsk82


People also ask

How do I enable xdebug log?

Enable Xdebug logging by adding the following line into php. ini: xdebug. remote_log=/log_path/xdebug.


2 Answers

In order to start the debugging somewhere else in your PHP code than at the start, you need to set xdebug.remote_mode=jitin php.ini. Then when you call xdebug_break the debugging session will start.

like image 198
Derick Avatar answered Sep 21 '22 15:09

Derick


xdebug_enable()
xdebug_disable()

void xdebug_enable() Enables stack traces

void xdebug_disable() Disables stack traces

http://xdebug.org/docs/all_functions

Also from the manual:xdebug_start_code_coverage, xdebug_get_code_coverage

<?php
    xdebug_start_code_coverage();

    function a($a) {
        echo $a * 2.5;
    }

    function b($count) {
        for ($i = 0; $i < $count; $i++) {
            a($i + 0.17);
        }
    }

    b(6);
    b(10);

    var_dump(xdebug_get_code_coverage());
?>  
like image 25
Laith Shadeed Avatar answered Sep 20 '22 15:09

Laith Shadeed