本貼子使用的環境 爲: win7 32 + PHP Version 5.2.17 thread safe +apache 2.2 + Zend Eclipse PDT +Studio Web Debugger
之前一直是搞J2EE的,最近公司要用到PHP,想自己搭下PHP的開發環境,怎耐周圍沒有熟悉的人。。。
只能自己動手豐衣足食,其中遇到不少困難,於是心想這PHP不是最流行的WEB開發語言麼,怎麼配置起來
這麼困難,本人認爲最困難的是eclipse +xdebug +zend debugger +php它們都有N個版本,能組合上統一的
版本是多麼的困難,儘管網上有N多教程,但看了之後發現和自己裝的都不一樣。
於是乎決定如果弄好這個環境一個一定要自己寫一個貼子,分享給大家。
PHP + APACHE安裝方法請參照上一篇
http://blog.csdn.net/gaochh01/article/details/6949178
這裏我們重點講eclipse的DEBUG調式環境
1.首先下載eclipsePDT,這裏有一個集成了所有PHP需要的組件的下載地址,有了它, 你就不用麻煩的去下eclipse又去找對應的php插件了,
它集成了所有php所要用的插件,具體請看下面的鏈接
http://www.zend.com/en/community/pdt/downloads
找到windows 版本的下載TAB頁,你需要下載 1. Zend Eclipse PDT PDT 3.0.2 w/Eclipse Indigo
2.Studio Web Debugger
分別解壓 eclipse-php-3.0.2.v20120511142-Win32.zip
和 ZendDebugger-20110410-cygwin_nt-i386.zip
你會發現 ZendDebugger-20110410-cygwin_nt-i386 下有N個文件夾,4_3_x_comp,4_4_x_comp。。。。。,這要選
哪一個是好呢? 別急,首先我們安裝的是PHP Version 5.2.17 thread safe 版本的php,所以我們選擇5_2_x_comp 文件夾裏的
內容,你要問了5_2_x_nts_comp 這個是作什麼的, 我來給你講一下他們的區別
5_2_x_comp 是針對 thread safe版本的php
5_2_x_nts_comp 是針對 non -thread - safe版本的php,因爲我們裝的是 PHP Version 5.2.17 thread safe,所以我們使用5_2_x_comp
打開5_2_x_comp 裏面有一個 ZendDebugger.dll文件
1).copy ZendDebugger.dll 到 [your php path]/ext/ 例如我的路徑爲:C:\Web\php\ext
2).打開 php.ini文件 在最後加上
[zend debugger]
zend_extension_ts="C:\Web\php\ext\ZendDebugger.dll";同樣注意ts和完整的路徑。這裏寫你自己的php安裝路徑
zend_debugger.allow_hosts=127.0.0.1;允許調試的主機IP,
zend_debugger.expose_remotely=always;
3).打開apache /conf/httpd.conf文件,在356行左右加入
Alias /pdt/ "D:/workspace3.3_PHP/"
<Directory "D:/workspace3.3_PHP/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
</Directory>
你又要問了 這是幹什麼?
其中D:/workspace3.3_PHP/ 是你eclipse的工作目錄 ,大概意思就是如果你請pdt它會給你轉到 D:/workspace3.3_PHP/,可能不太準確
但意思差不多
重啓apache後,你就可以直接通過 http://localhost/pdt/去直接訪問eclipse工程中的D:/workspace3.3_PHP/ 文件了,這會在之後用到
4).copy C:\Web\php PDT\ZendDebugger-20110410-cygwin_nt-i386 中的 dummy.php到 appache /conf/htdocs 文件夾內重啓 apache 服務
如果你在phpinfo()中看到
Zend Debugger
Passive Mode Timeout | 20 seconds |
Directive | Local Value | Master Value |
---|---|---|
zend_debugger.allow_hosts | 127.0.0.1 | 127.0.0.1 |
zend_debugger.allow_tunnel | no value | no value |
zend_debugger.deny_hosts | no value | no value |
zend_debugger.expose_remotely | always | always |
zend_debugger.httpd_uid | -1 | -1 |
zend_debugger.max_msg_size | 2097152 | 2097152 |
zend_debugger.tunnel_max_port | 65535 | 65535 |
zend_debugger.tunnel_min_port | 1024 | 1024 |
那麼恭喜你,已經成功一半了
,接下來我們打開eclipse PDT,當然我們的workspace是之前apache httpd.conf 配置中的D:/workspace3.3_PHP/
1). windows ----> preference ---> PHP----->PHP Executables ----------->add
name : test 此項隨意
Exceutable path: C:\Web\php\php.exe 你自己的php安裝路徑
PHP ini file :C:\Web\php\php.ini 你自己的php安裝路徑
SAPI TYPE: CLI
PHP debugger: Zend Debugger
然後確認保存
2).windows ----> preference ---> PHP---------> PHP Servers
name : Default PHP Web Server 隨意
Base URL: http://127.0.0.1
local Web Root: 空
然後確認保存
3). windows ----> preference ---> PHP------------->Debug
PHP Debugger : Zend Debugger
Server: Default PHP Web Server(2中配置的)
PHP Excutable:test (1 中配置的)
4).Enable CLI Debug 前面勾打上
然後確認保存
5).新建一個PHP工程 name:test
新建一個php文件 new.php
輸入: <?php print("hello world!"); ?>
6):點擊debug configuration ----------->PHP Web Application
雙擊新建一個configration Name :隨意
Server
Debugger: Zend Debugger
PHP Server : Default PHP Web Server (之前步驟中創建的)
File : 選中 /test/new.php
URL 下 auto Generate 前面的勾去掉
URL: http://127.0.0.1/ /pdt/test/new.php這處注意修改
你又要問了 爲什麼要加pdt ?? ,因爲我們之前在apache /conf/httpd.conf
Alias /pdt/ "D:/workspace3.3_PHP/"
<Directory "D:/workspace3.3_PHP/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
</Directory>
如果不加pdt 默認請求的是C:\Web\apache\htdocs目錄下的文件,就會提示找不到
/test/new.php,這樣你知道爲什麼要加ptd 了吧
然後點擊debug,你就可以像調試java一樣在new.php中打斷點進行調試了