how to debug opencart project ? for example putting break points step into code etc?

11,263

Solution 1

I wrote a super simple little function for the loader class that I use 100 times a day. It really helps and you can call it from just about anywhere.

OPEN:

system/engine/loader.php

Right before the closing brace for the class add this method:

// adding testing method
public function test ($items, $quit = true) {
    echo "<pre>";
    print_r ($items);
    echo "</pre>";

    if ($quit):
        exit;
    endif;
}

Now anytime after the Controller is instantiated you can call:

$this->load->test($results);

OR:

$this->load->test($results, false);

if you're in a loop and don't want the script to exit.

Obviously substitute $results for whatever array or variable you want to test.

It's been a huge help to me.

You can of course add this via vqmod if you don't want to modify the core.

Solution 2

You are right. Opencart is very simple system. In addition you can use xDebug - very useful tool. Also, read system/logs/error.txt

error_reporting(E_ALL); // very helpful
die(print_r($_POST, true)); // print all POST data and break the code

Solution 3

you can use https://github.com/mithereal/opencart_inline_debuggers and just d($var); in the source where var is a varible or object

Share:
11,263
sivakumar
Author by

sivakumar

working as a Magento developer at Kensium Solutions(Hyderabad India).

Updated on June 04, 2022

Comments

  • sivakumar
    sivakumar about 2 years

    I'm new one to opencart.is there any debug tools available for opencart ? .i don't know control flow of opencart execution.so i want to put break points,step into code,see variable values. please give any reference to that .thanks in advance.