In this article you will read something about debuging modules and other shop problems. This article should be taken as an introduction to self-troubleshooting in the own store. This tutorial works in all versions of prestashop, in 1.5 too.
If you have got newest prestashop (1.5.3 or higher) you need to read new tutorial - just click here
What exactly is error log or error reporting?
If you are running into a white shop page or some other PHP error, if something doesn't work properly in your shop based on PrestaShop engine, if something is wrong with any presta module or addon - but you have no clue what is wrong, you should consider turning on PHP error reporting. This will give you some indication of where or what the problem is. This is a good first step to solving your problem. In simple words is a web server mode which provides you and other users to read about errors, warnings, notices in your website code. By default, in PrestaShop this feature is disabled for safety reasons. Here is how to turn on PHP errors in shops based on PrestaShop:
Open and edit config.inc.php file
Yyou first need to find the config.inc.php file in directory config in your main prestashop dir, exactly as we show on image below:
you must open this file and edit one setting parameter:
1 |
<span style="color: #339933;" data-mce-style="color: #339933;">@</span><a href="http://www.php.net/ini_set" data-mce-href="http://www.php.net/ini_set"><span style="color: #990000;" data-mce-style="color: #990000;">ini_set</span></a><span style="color: #009900;" data-mce-style="color: #009900;">(</span><span style="color: #0000ff;" data-mce-style="color: #0000ff;">'display_errors'</span><span style="color: #339933;" data-mce-style="color: #339933;">,</span> <span style="color: #0000ff;" data-mce-style="color: #0000ff;">'off'</span><span style="color: #009900;" data-mce-style="color: #009900;">)</span><span style="color: #339933;" data-mce-style="color: #339933;">;</span> |
as you probably see and as we say, the display_errors value is set to off by default. You must turn it on. How to do that?
just change 'off' param to 'on' exactly as below:
1 |
<span style="color: #339933;" data-mce-style="color: #339933;">@</span><a href="http://www.php.net/ini_set" data-mce-href="http://www.php.net/ini_set"><span style="color: #990000;" data-mce-style="color: #990000;">ini_set</span></a><span style="color: #009900;" data-mce-style="color: #009900;">(</span><span style="color: #0000ff;" data-mce-style="color: #0000ff;">'display_errors'</span><span style="color: #339933;" data-mce-style="color: #339933;">,</span> <span style="color: #0000ff;" data-mce-style="color: #0000ff;">'on'</span><span style="color: #009900;" data-mce-style="color: #009900;">)</span><span style="color: #339933;" data-mce-style="color: #339933;">;</span> |
If you want advanced errors information (notices too) you should add new line:
1 |
<a href="http://www.php.net/error_reporting" data-mce-href="http://www.php.net/error_reporting"><span style="color: #990000;" data-mce-style="color: #990000;">error_reporting</span></a><span style="color: #009900;" data-mce-style="color: #009900;">(</span><span style="color: #0000ff;" data-mce-style="color: #0000ff;">"E_ALL"</span><span style="color: #009900;" data-mce-style="color: #009900;">)</span><span style="color: #339933;" data-mce-style="color: #339933;">;</span> |
error_reporting parameter can have several settings, like:
Parameter value | Description |
---|---|
E_ERROR | Fatal run-time errors. Errors that can not be recovered from. Execution of the script is halted |
E_WARNING | Non-fatal run-time errors. Execution of the script is not halted |
E_PARSE | Compile-time parse errors. Parse errors should only be generated by the parser |
E_NOTICE | Run-time notices. The script found something that might be an error, but could also happen when running a script normally |
E_CORE_ERROR | Fatal errors at PHP startup. This is like an E_ERROR in the PHP core |
E_CORE_WARNING | Non-fatal errors at PHP startup. This is like an E_WARNING in the PHP core |
E_COMPILE_ERROR | Fatal compile-time errors. This is like an E_ERROR generated by the Zend Scripting Engine |
E_COMPILE_WARNING | Non-fatal compile-time errors. This is like an E_WARNING generated by the Zend Scripting Engine |
E_USER_ERROR | Fatal user-generated error. This is like an E_ERROR set by the programmer using the PHP function trigger_error() |
E_USER_WARNING | Non-fatal user-generated warning. This is like an E_WARNING set by the programmer using the PHP function trigger_error() |
E_USER_NOTICE | User-generated notice. This is like an E_NOTICE set by the programmer using the PHP function trigger_error() |
E_STRICT | Run-time notices. PHP suggest changes to your code to help interoperability and compatibility of the code |
E_RECOVERABLE_ERROR | Catchable fatal error. This is like an E_ERROR but can be caught by a user defined handle (see also set_error_handler()) |
E_ALL | All errors and warnings, except level E_STRICT (E_STRICT will be part of E_ALL as of PHP 6.0) |
Which parameter value we must use?
in our opinion the best for use is E_ALL
so set the parameter value to:
1 |
<a href="http://www.php.net/error_reporting" data-mce-href="http://www.php.net/error_reporting"><span style="color: #990000;" data-mce-style="color: #990000;">error_reporting</span></a><span style="color: #009900;" data-mce-style="color: #009900;">(</span><span style="color: #0000ff;" data-mce-style="color: #0000ff;">"E_ALL"</span><span style="color: #009900;" data-mce-style="color: #009900;">)</span><span style="color: #339933;" data-mce-style="color: #339933;">;</span> |
and save the config.inc.php file.
now you can refresh your shop, and you will see errors, warnings and notices from PHP script interpreter. Now you can localize issues in your code, module codes or something else with errors :)