-->

How to debug magento application

2020-02-19 08:07发布

问题:

I am working with Magento but i didn't find a very good way to debug my modules. For example, many time, i got a blank page with no php error and no apache error. For example, in backend, if one grid controller isn't well set, i don't have an error.

How to debug Magento module?

回答1:

It sounds like you want to enable Developer mode. Add this to your .htaccess file:

SetEnv MAGE_IS_DEVELOPER_MODE "true"

You may also want to enable display errors in index.php:

 ini_set('display_errors', 1);

The best way I have found to debug is with X-Debug in a local environment. You can also use log files to help debug in a production environment, if your unable to run X-Debug in the environment.

I've got a more detailed posting here:

  • https://gist.github.com/molotovbliss/2792c6c59410d75e5baf249b76413247

Consider also installing XDebug



回答2:

This thread is old but useful. Debugging tools and tricks are important as it saves lots of time of a developer.

Here is a compiled list My company Uses.

  1. Use of Eclipse debugger: Magento is installed on a desktop using Eclipse debugger we apply breakpoints and other debugging tricks.

  2. Use of Bug commerce as suggested in above post.

  3. Use of Mage::log for error log and exception log.Also Magento Report files.

  4. Use of Varien Object getData, debug.

  5. Use of back trace: Mage::log(Varien_Debug::backtrace(true, true), null, 'backtrace.log')

  6. Remote server level debugging.

  7. var_dump PHP function to echo and exit.



回答3:

If you are (want to be) a real Magento Developer, here is the best combination of IDE and plugin you must use to work on your Magento Projects.

  1. First of all, phpStorm the best IDE you can find.
  2. Exist a very helpful plugin called magicento that you can use auto-complete, find in path magento, create modules very quickly and without issue, other great stuff you can use with that plugin.
  3. Of course need to install Xdebug (be carefully if you already run a project with ioncube, bc you need to make some trick there, Xdebug doens't work properly with ioncube loader).
  4. This last item on the list is something I need to be reviewing but I think should be great to debugging porpoises, MagentoDebugger Chrome App.

Let me know if you need something else or any help installing some of the stuff.

Best, Alejandro.



回答4:

You can look in var/log/exception.log or system.log in the magento root. These are the directories for Magento excepetions and logs. Otherwise you might need to increase the php error log level.

Alan Storm created a Commerce Bug to help with some inline development issues.



回答5:

Please try to use this magento debugger, it's chrome extension. http://w3site.org/magento_debugger it's realy speeds up a work. Just need to configure on the backend once and use Chrome extension.

Here easy to debug blocks, mails. Easy profile your extensions, etc.