wamp server 如何配置 xdebug

wamp server 如何配置 xdebug

Netbeans 的网站上已经详细描述了如何配置的问题,但没有用PHP 5.3举例,这里就要注意一个问题,一个是到xdebug网站下载的时候必须下载对应5.3的版本5.3 VC6 (32 bit) ,另外5.3的php.ini应该这样写:

zend_extension ="C:/wamp/bin/php/php5.3.0/ext/php_xdebug-2.0.5-5.3-vc6.dll"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000

How to configure xdebug on WAMP
  • installing xdebug on WAMP is a bit diferrent and requires another steps to sucesfully load module. I focus on the easiest use case, installation using precompiled .dll.
Prerequisities
  • I assume these prerequisities:
    • you have latest version of WAMP installed. That's WAMP 2.0 when writing this tutorial (Apr 15, 2009). These includes:
      • Apache 2.2.11
      • PHP 5.2.9-1
      • I don't care about MySQL at this moment ..,
Steps
  • if you didn't customize your installation paths then you should find php in <wamp_folder>/bin
C:.
├───apache
│   <some folders>
├───mysql
│ <some folders>
└───php
└───php5.2.9-1
├───dev
├───ext
├───extras
│ ├───mibs
│ ├───openssl
│ └───pdf-related
└───PEAR
  • folder ext is used for extension and we used it to copy xdebug's dll there. However, you can use whatever folder you want.
  • download xdebug from http://www.xdebug.org/download.php. Carefully choose version you download! There is a description you should read on download page! I downloaded php_xdebug-2.0.4-5.2.8.dll for WAMP2 with prerequisities above. Consult our FAQ at the end of this page if you need more help on choosing a version.
  • open your php.ini that is easily accesible from tray. Wamp tray icon -> PHP -> php.ini
  • add following lines to your php.ini. Use full path! (change your .dll name to match your version, of course)
zend_extension_ts="C:/wamp/bin/php/php5.2.9-1/ext/php_xdebug-2.0.4-5.2.8.dll"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
  • NOTICE: From PHP 5.3 onwards, you need to use zend_extension and not zend_extension_ts.
  • note that you always use zend_extension_ts unless you intentionally installed non thread safe apache version
  • restart WAMP services (restart Apache is enough)
  • open localhost (or WAMP server default page) and check if xdebug is between Loaded Extensions
  • click on phpinfo() on default WAMP page or create file containing <? phpinfo() ?>. You should see the same as for Linux tutorial above:
  • You can check your configuration using simple script written by Radek Matous and posted on blog.sun.com . If you are using WAMP then you don't have php on path, most probably. All you have to do is to copy this code to php file and then call it from browser with $_GET variable in url ?XDEBUG_SESSION_START=mysession. Let's say your file i called dbgtest.php and it's in web directory. All you have to do is type http://localhost/dbgtest.php?XDEBUG_SESSION_START=mysession.
  • If xdebug is properly installed then script started in step 1. should print message like "connection established: Resource id #5". If no message is printed and the script is still running, then xdebug isn't installed properly or uses different port or whatever else. So, kill the running process and investigate where the problem is, but this is the other story.
<?php
$address = '127.0.0.1';
$port = 9000;
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($sock, $address, $port) or die('Unable to bind');
socket_listen($sock);
$client = socket_accept($sock);
echo "connection established: $client";
socket_close($client);
socket_close($sock);
?>
Troubleshooting
  • if something goes wrong then check your PHP Error Log that you can find after invoking WAMP context menu from system tray
    • e,g,: WAMP icon -> PHP -> Error Log
  • Probably typo or file was not found if you see this:
PHP Warning:  PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.2.9-1/ext/php_xdebug-2.0.4-5.2.8.dl' 
- The specified module could not be found.
in Unknown on line 0
  • You downloaded wrong version of php.ini if you see following:
PHP Warning:  PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.2.9-1/ext/php_xdebug-2.0.4-5.3.0-vc9.dll' - 
The application has failed to start because its side-by-side configuration is incorrect.
Please see the application event log for more detail.
in Unknown on line 0
  • Do NOT use XAMPP 1.7.0. If you set up XDebug as described here, the Apache server crashes when you run or debug a file or project. The workaround prevents the IDE from stopping at breakpoints. XAMPP 1.7.1 is fine, with XDebug 2.0.4 VC 5.2 thread-safe.
  • try to check Apache Error Log as well.

你可能感兴趣的:(apache,PHP,server,socket,Zend,extension)