PHP Smarty var_dump alternative and prestashop errors

→ Are you a new visitor? Please visit the page guidance for new visitors ←

PHP Smarty var_dump alternative and prestashop errors

If you work on prestashop for example, and you want to make a debug for all or a certain variable from within a page you will have problems because you cannot use var_dump since Smarty is a templating language for PHP.

Method 1

Method 2

Method 3

Prestashop issues

You may sometimes encounter a fatal error in PrestaShop, often when using an old module with a new version of PrestaShop.  These error messages don’t provide any information you can use to debug.  In that case, you can get a stack trace to help you locate the error by changing '_PS_MODE_DEV_' near the top of config/defines.inc.php to true.

Smarty console to view a list of the available variables and their values.  In PrestaShop v1.5 and later, you can turn on the Smarty console on the Preferences > Performance tab:

smarty debug

smarty debug

By default, the Smarty console is not displayed.  You can change the setting to “Always open console” to have the console always open, but then your customers will see it too, so if your website is online, it is better to choose the “Open console with URL parameter (SMARTY_DEBUG)” option.

You can see the debug console in action below:

debug

From here, you can see all variables that are available in the page that you are on frontend.

 

Request an article ←