Dephpugger

Dephpugger

  • Docs
  • About Us

›Usage

Dephpugger

  • About

Installation

  • Dependencies
  • XDebug
  • Composer
  • Browser Plugin
  • Dephpugger

Usage

  • Usage Video Tutorial
  • Running Dephpugger
  • Commands to Run
  • Running for Web
  • Running with PHPUnit

Configuration

  • File Configuration
  • Lumen
  • Laravel
  • Zend Framework 2
  • Symfony
  • Slim
  • Silex
  • Yii2

Commands to Run

Commands

When the debugger stop in a breakpoint, it wait the developer send commands to navigate in code.

Create a file called quicksort.php (or with another algorithm). We will use this file for example.

<?php
$unsorted = array(43,21,2,1,9,24,2,99,23,8,7,114,92,5);

function quick_sort($array)
{
    $length = count($array);
    if($length <= 1){
        return $array;
    } else {
        $pivot = $array[0];
        $left = $right = array();
        for($i = 1; $i < count($array); $i++)
        {
            if($array[$i] < $pivot){
                $left[] = $array[$i];
            } else {
                $right[] = $array[$i];
            }
        }
        return array_merge(quick_sort($left), array($pivot), quick_sort($right));
    }
}

xdebug_break();

$sorted = quick_sort($unsorted);

echo 'Unsorted numbers: ',implode(', ', $unsorted).PHP_EOL;
echo 'Sorted numbers: '.implode(', ', $sorted).PHP_EOL;

Run in different terminals.

$ dephpugger debug # in first terminal
$ dephpugger cli quicksort.php # in another terminal

The debugger is waiting you to run a command. If you run the command help, you will see all possible commands.

CommandAliasExplanation
nextnTo run a step over in code
stepsTo run a step into in code
set <cmd>:<value>Change verboseMode or lineOffset in runtime
continuecTo continue script until found another breakpoint or finish the code
listlShow next lines in script
list-previouslpShow previous lines in script
helphShow help instructions
$variableGet a value from a variable
$variable = 33Set a variable
my_function()Call a function
dbgp(< command >)To run a command in dbgp
quitqExit the debugger

Now you can navigate in the algorithm and investigate.

Press n to go to the next line, if exists.
Press s and press enter to get inside the method.
Press l to see the next lines.
Press lp to see the previous lines.
Key the variable name to get the value and type.
You can change the variable value in runtime.

See example

← Running DephpuggerRunning for Web →
  • Commands
  • See example
Dephpugger
Docs
Getting StartedUsageConfiguration Reference
Articles and Videos
How debug Drupal applicationsSingapore PHP User GroupHow debug PHP in terminal
More
BlogGitHubStar
Copyright © 2024 Tacnoman