PrestaShop tries its best to make it easy for developers to build clean and working themes, modules and overriding classes. This is done through a set of developer tools that you can enable whenever you needs them.
By default, PrestaShop turns error reporting off, which makes that if your code fails, you will see a blank page with no information. This is because customers should not see anything from your server. You can get a lot of information using the following tools.
Most of these tools should only be enabled when you are in the development process, on your local installation. If you have to enable them on a production store, you should first disable the store so that only you can see the results of your tests.
PrestaShop's developer mode enables a series of tools to help developers:
display_errorsto "on": errors are displayed in the browser instead of just blank pages.
_PS_DEBUG_SQL_constant to "true": PrestaShop displays potential problems within your SQL queries.
_PS_DISPLAY_COMPATIBILITY_WARNING_constant to "true": PrestaShop displays a warning message if a piece of code you are using is deprecated in the current version.
All in all, this mode displays a lot more error messages than the regular mode.
Enabling it is quite easy:
Now reload any blank or suspicious page: you should get a lot more information.
PHP developers are used to regularly call
print_r($var) in order to know what lies inside
$var. In order to properly display the content of $var, they often encapsulates
print_r() within HTML or XML tags.
PrestaShop does that for you!
d() are both wrappers around
p() returns the content of the variable, while
d() finishes with
On top of that, PrestaShop defines the
ddd() method, which are respectively the aliases of
d(). They work exactly the same, but are often easier to search and find in a huge block of code.
These debug methods are not available by default. To activate them, you must enable the Developer mode (see above).
PrestaShop's profiler is a great way to discover the bottlenecks in your code: once enabled, each page on either the front-end or the back-end of your store will display a lot of information about the page and its files:
This is a huge step in knowing which files or SQL query you should work on when you need to improve the performance of your store.
Enabling it is quite easy:
Now load any page of your store, either front-end or back-end, and it will display a lot of statistics at the bottom of the page, below the regular content of that page.
In order to disable the Profiling Mode, simply open the defines.inc.php file and change the value back to "false" in the line mentioned above.
Here is the result from the home page:
Here is the result from the back-office: