巴鲁's profile岩屋PhotosBlogListsMore Tools Help

Blog


    September 20

    使用Xampp和Eclipse/PDT调试PHP程序

    上午看到一篇文章关于PHP调试的新消息,安装加调试一共用了一个小时,最终成功运行了,以后可以用新方法调试了,太爽了。哈哈。

    注意:如果你机器已经安装了MYSQL和PHP,ASP等占用了端口号,请自己更改http.conf文件,自行更改。然后运行XAMPP文件夹下的apache_start.bat即可,呵呵,这个问题折磨我好一阵子。

    正好这有一个别人写的调试过程(原文地址):http://www.yulei.org/mambo/index.php?option=com_content&task=view&id=17&Itemid=6

    现在分享成果如下:

    Eclipse下目前有几种PHP插件,但是最好的一种肯定是Eclipse官方的PDT,其网页在:
    http://www.eclipse.org/pdt/

    下载方法不多说了,最方便的下载就是下载AllinOne这样的东西,这里给个连接,包含了Zend的调试器的AllInOne:http://www.zend.com/pdt#all_in_one

    XAMPP现在无疑是大家研究apache/mysql/php/perl 的首选,安装配置非常方便,它在http://www.apachefriends.org

    可以从这里下载最新的Windows版本的Xampp: http://www.apachefriends.org/zh_cn/xampp-windows.html

     XAMPP和Eclipse都是绿色软件,下载下来就能直接使用了,这个不屑多说了。现在说说让XAMPP的apache服务器配成我们的网站,同时又让Eclipse/PDT来调试我们网站上的PHP程序。

     首先我这里假定我的XAMPP,Eclipse都安装在F盘下,就是F:\Xampp 和 F:\Eclipse 并且 我的工作目录也在F盘下的F:\Workspace

    启动Eclipse以后,工作空间选择:F:\Workspace

    好了,现在我们就可以开始试验一个新的PHP项目了,假定新项目名称是testmyphp

    Eclipse中选择新建一个PHP项目。然后创建一个PHP文件,就如同下图,我在其中的第三行设置了一个断点

    Image

    为了方便起见,我们配置一下把我们的F:\workspace\testmyphp作为我们整个网站的目录

    因此需要配置F:\xampp\apache\conf\httpd.conf,加一段

    <Directory "F:/Workspace/testmyphp">
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
    </Directory>

    同时把原来的:

    DocumentRoot "F:/xampp/htdocs"

    改成:

    DocumentRoot "F:/Workspace/testmyphp"

      关于Apache目录的配置,这里不多说了。

    然后就是配置一下Xampp中的PHP的Debugger了,在缺省情况下Xampp中的PHP使用了Zend的加速器,现在要把它改成Zend的Debugger

    注意:Xampp的PHP执行程序虽然在F:\Xampp\Php目录,但它的配置却是在F:\Xampp\Apache\bin目录下的,打开F:\ Xampp\Apache\bin\php.ini 找到zend_extension_ts=....之所在,下面是缺省的样子:

    zend_extension_ts = "F:\xampp\php\zendOptimizer\lib\ZendExtensionManager.dll"

     把它改成:

    zend_extension_ts = "F:\eclipse\plugins\org.zend.php.debug.debugger.win32.x86_5.2.6.v20070507\resources\php5\ZendDebugger.dll"

    这个ZendDebugger.Dll就是刚才从Zend下载来的Zend的调试器的AllInOne的Eclipse中的Zend调试器。

    然后重启Apache。

    然后我们使用Debug中的PHP Web Page方式

    Image

     看看,现在我们设的断点起作用了,可以调试程序了:

    Image

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://snowyrock.spaces.live.com/blog/cns!B8CBEB7169880B1D!397.trak
    Weblogs that reference this entry
    • None