Version 1.1.4 (22 Mar 2020)
If you are not actively editing PHP code, this mod is not for you !
New OCMOD version for Opencart 3.x
How frustrating is it when you're trying to develop a mod and you're getting unexpected results. To try and establish where the script is going wrong or falling over can be quite tricky, especially when you can't "echo" valuable information to the screen. I got fed up writing several lines of code in order to capture certain information or write it to a file, so I developed the "Simple Debug Tool'. With one line of code at the appropriate point, I can leave messages, record the value of variables and the content of arrays.
Whether you're trying to debug the controller or model files, the catalog or the admin side of your mod, just a simple line of code puts all the information you're looking for into a log file where you can easily check what's happening.
This simple modification extends the "Log" class and adds 3 new methods:
This line of code writes $output
to a file system/logs/debug.txt
can be a string, a variable or an array and can be helpful in debugging a script that is giving unexpected results. Simply add the line at an appropriate point in the script eg.
- $this->log->debug('I have reached "X" point in the script'); (Adds the string to the log)
- $this->log->debug($language_id); (Adds the content of the variable $language_id to the log)
- $this->log->debug($this->request->post['status']); (Adds the content of the POSTed variable 'status' to the log)
- $this->log->debug($this->request->post); (Adds the content of the complete POST array to the log)
- $this->log->debug($this->session->data['user_id']); (Adds the content of the session variable 'user_id' to the log)
- $this->log->debug($query->rows); (Adds the selected database data to the log)
You can use an optional second parameter to provide a "label" for the output eg:
$this->log->debug('The complete POST array', $this->request->post);
This has the same effect as if you had written two separate lines of code eg:
$this->log->debug('The complete POST array');
Simply empties the log file so you don't have to scroll to the end of a long file if you haven't deleted previous entries.
IMPORTANT. This Extension requires that you have VQMod installed.
If VQMod is not installed you can obtain it free from here : https://github.com/vqmod/vqmod/wiki
Simply extract the files from the archive and copy the vqmod folder to the root folder of your store.