使用Zend studio已经很久了,今天依然发现其中的很多功能我没有好好的利用起来,更好的利用好,我觉得能有效的提高效率。尽管使用eclipse这样的工具很久了,其中的宝藏
还是没有好好开发,今天讲讲如何使用zend studio中的zend debug进行代码调试。
在安装完zend studio之后,一般zend debug就默认安装好了,应该算是集成在一起的。如果发现没有集成进来,请到zend 的官方网站上面下载一个ZendServer-CE-php-5.2.17-5.1.0-Windows_x86.exe,记住是社区版,免费的,其中集成了很多功能,比如apc,zend debug,apache,php,mysql...
相当于是一个集成的环境,然后加上zend studio,这样相得益彰。而且调试起来也会非常方便。
基本的流程如下:
(1)设置PHP Servers,
(2)编辑其中的某个PHP Server,主要设置其根目录,这里的根目录,应该是和httpd.conf中设置的虚拟目录相当。
这里设置好了主要的调试路径的根地址,
(3)点击调试图标,会出现一个下拉选项,选择, 这里需要设置一下调试的url地址等信息:
右下角的地址就是你想调试的url,上面的File,是要选择该调试的url地址,最初对应的哪个文件,相当于是作为入口文件一样,用户如果选择了
"Break at First Line", 默认会从入口文件的第一行,进行代码的调试,如果没有勾选,会从用户设置的断点开始进行调试(双击某行代码即可)。
我想说明下的,在调试的时候,有个选项,,相当于是参数跟踪,非常有效,效果如下:
是从
下面可以对照一下虚拟目录的配置:
# # Virtual Hosts # # If you want to maintain multiple domains/hostnames on your # machine you can setup VirtualHost containers for them. Most configurations # use only name-based virtual hosts so the server doesn't need to worry about # IP addresses. This is indicated by the asterisks in the directives below. # # Please see the documentation at # <URL:http://httpd.apache.org/docs/2.2/vhosts/> # for further details before you try to setup virtual hosts. # # You may use the command line option '-S' to verify your virtual host # configuration. # # Use name-based virtual hosting. # NameVirtualHost *:80 # # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for all requests that do not # match a ServerName or ServerAlias in any <VirtualHost> block. # <Directory "D:\Program Files\Zend\Apache2\htdocs\Discuz"> AllowOverride None Options None Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "D:\Program Files\Zend\Apache2\htdocs\Discuz" ServerName bbs.l00818.com.local ErrorLog "logs/bbs.local.log" </VirtualHost>
只要从httpd.conf中引入:
Include conf/extra/httpd-vhosts.conf
配置就生效了。
下面谈下关于添加, 有时候有些代码很长,一次无法完全调试结束,于是需要写个todo List,下次可以非常方便的到同一个位置:
或者对于一些需要经常编辑的文件,添加todo list,可以非常快速的找到对应的地方。不用每次在一个庞大的系统中,一个个的进行搜素。
比如下面的,就是可以方便的找到某个问题的跟踪,
在某个需要添加todo的地方,右键单击:
就OK 了。
还有Firefox 的调试插件,可以非常方便的与zend studio进行联动调试,非常方便,大家有兴趣可以看看我的另外一篇博文:
http://blog.csdn.net/jallin2001/article/details/6268589
我依然觉得写PHP,调试是个很重要的基本技能。对于团队开发,其内置的SVN也是很有帮助的。