为了工作,不得不掌握debug的方法。因为我是一个很挫的程序员,写的代码质量可想而知。如果弄出很多问题来,则我工作的主要任务就是解决各种bug,轻轻松松挖坑,然后花大部分工作时间埋坑。
因此,我觉得可以从两个方面来提高我的工作效率:
一、从源头上减少出错
严格遵循相关的编码规范,多思考逻辑,遵循最佳实践。此外,使用标准的开发流程和工具也能避免引入低级错误。
二、掌握调试方法
快速定位问题,减少问题解决的时间。
下面我直接把stackoverflow网站上的几个人的方法摘录下来。我就按照这个去debug就好。
—— By Satish Mantri
Here is a compiled list My company Uses.
-
Use of Eclipse debugger: Magento is installed on a desktop using Eclipse debugger we apply breakpoints and other debugging tricks.
-
Use of Bug commerce as suggested in above post.
-
Use of Mage::log for error log and exception log.Also Magento Report files.
-
Use of Varien Object getData, debug.
-
Use of back trace: Mage::log(Varien_Debug::backtrace(true, true), null, 'backtrace.log')
-
Remote server level debugging.
-
var_dump PHP function to echo and exit.
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.
- First of all, phpStorm the best IDE you can find.
- 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.
- 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).
- 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.
附录:
原文:
http://stackoverflow.com/questions/7474245/how-to-debug-magento-application
https://www.sonassi.com/knowledge-base/magento-debug-process/