Debugging

Debugging is a process of detecting and fixing of existing and potential errors in code that can cause it to behave unexpectedly.

Qauntum comes with `Debugger` library based on maximebf/php-debugbar package. The Debugger, once enabled, will show the Debugbar at the bottom of the page. The Debugbar is set of tabs that display various debug information about the current request, route, queries, variables states and more.

The simplicity of using Debugger, is to just enable it from the .env file by setting DEBUG=true.
Once it's enabled, a new Debugbar will appear at the page bottom.

The Debugbar consist in 4 tabs: Messages, Request, Queries and Routes and displayes the appropriate content of each when available.

The Route tab shows information about current route, including current Module, Controller, View, etc.


array:7 [
  "Route" => ""
  "Method" => "GET"
  "Module" => "Main"
  "Controller" => "modules\Main\MainController"
  "Action" => "indexAction"
  "View" => "modules/Main/Views/index"
  "Args" => []
]

        

The Request tab shows the request content, including $_GET, $_POST, $SERVER, etc.
To see the content of specific variable, you need to click on it to expand its content.


$_GET []
$_POST []
$_SESSION array:2 [ "LAST_ACTIVITY" => 1549712829 "PHPDEBUGBAR_STACK_DATA" => [] ]
$_COOKIE array:1 [ "PHPSESSID" => "8ssg41tksndcq512fp0fahuj47" ]
$_SERVER array:29 [ "DOCUMENT_ROOT" => "C:\Users\Comp\Desktop\debugger\public" "REMOTE_ADDR" => "::1" "...
$_ENV array:6 [ "DB_DRIVER" => "mysql" "DB_HOST" => "localhost" "DB_NAME" => "qtproject" "DB_USERN...

        

The Queries tab will show content only when any interaction with database took place.


$user = $userModel->findOneBy('user_id', 2)->asArray();

        

Once database interaction happen, the Queries tab will show appropriate information.


SELECT * FROM `user` WHERE `user_id` = '2' LIMIT 1

        

The Messages tab will display anything that outputed via out() helper function.

Note* That if in the .env file DEBUG=false, the out() function will directly output the variable dump into web page content.

In the code bellow you will see new object is defined with several properites and then outputted via out() function.


$obj = new \stdClass();
$obj->weight = 50;
$obj->height = 10;

$obj->props = [
    'first' => 12,
    'second' => 'ssd',
    'third' => 'backlog'
];

out($obj);

        

In the Messages tab the output will look like this.


{#94
  +"weight": 50
  +"height": 10
  +"props": array:3 [
    "first" => 12
    "second" => "ssd"
    "third" => "backlog"
  ]
}

        

If multiple out() functions are used, the output will be displayed in the order of their appearance.


array:5 [ "user_id" => "2" "username" => "fernando" "password" => "777888" "age" => "17" "...
{#94 +"weight": 50 +"height": 10 +"props": array:3 [ "first" => 12 "second" => "ssd" ...

        

You need to click on each of them to expand the content.

<< Prev Next >>