Powered by Blogger.

Coba Xdebug di Xampp windows, mudah

iseng-iseng coba fasilitas debug yang disediakan xampp.

dari http://optimizely-to-drupal-8.blogspot.co.id/2014/07/setting-up-xdebug-with-sublime-text-2.html 

Setting up xDebug with Sublime Text 2 on Windows

I have gotten deeply enough into working with the PHP code of the Optimizely module that I missed having a debugger to step through the flow, examine the values of variables, and in general to dynamically control and understand the execution of the code.

Here are steps I took to successfully install and configure the xDebug PHP debugger to work with Sublime Text 2  (version 2.0.2) on a Windows 7 system.


(1) Installed xDebug 2.2.5 extension for PHP.

(a)  Downloaded php_xdebug-2.2.5-5.4-vc9.dll from  http://www.xdebug.org/download.php  and placed it into C:/php/ext (or wherever you might have PHP installed).

Since I wasn't sure which version of the dll to use, I followed the "custom installation instructions" on the xDebug site, which were very helpful and indicated which dll should work on my system.

(b)  Edited php.ini, adding the following line
zend_extension = ext\php_xdebug-2.2.5-5.4-vc9.dll
(c)  Restarted Apache. Loaded a page containing a call to phpinfo() to check that the extension was installed. On the page there appeared an xdebug section with several tables that showed settings and directives.


(2) Installed the Sublime package manager, "Package Control".

(a)  Within Sublime, clicked Preferences > Browse Packages, then browsed up one level to find the full path for the Installed Packages folder. On my system the path is

  C:/Users/Earl/AppData/Roaming/Sublime Text 2/Installed Packages

(b)  Downloaded the file Package Control.sublime-package from  https://sublime.wbond.net/Package%20Control.sublime-package

(c)   Copied that file into the Installed Packages folder.

(d)  Re-started Sublime.

In Sublime's Command Palette window, various Package Control commands were then available on the palette, such as Package Control: Install Package. You can also get to Package Control via the menu bar, Preferences > Package Control.


(3) Using Sublime's Package Control, installed the Xdebug Client package.

A couple of clicks. Done. In Sublime, this adds a submenu, Tools > Xdebug, or you can use the keyboard equivalents.


(4) Added further directives to php.ini for xDebug.

In php.ini created an [xdebug] section which includes the zend_extension directive added mentioned above.
[xdebug]
zend_extension = ext\php_xdebug-2.2.5-5.4-vc9.dll
xdebug.remote_enable = 1
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port = 9000
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = req
xdebug.remote_connect_back = 0
Because I only want to debug locally, I set xdebug.remote_connect_back to 0 to turn it off. I believe this should be set to 1 if you intend to debug a site running on a remote system, but my understanding of these directives is pretty fuzzy at this point.


(5) To start an xDebug session.

To start a debugging session, I am loading the Drupal 8 site that contains the converted Optimizely module by appending the query string ?XDEBUG_SESSION_START=1  to the usual url, like so:
http://localhost/opti/index.php?XDEBUG_SESSION_START=1
The value of  XDEBUG_SESSION_START  is a session name that is stored in a cookie, so it could be any name you choose.

There are other ways to start an xDebug session, but for getting started with using this debugger, this seemed like the simplest. Later, I may try to use one of the browser extensions that are available.

Finally, in Sublime itself, I do Start Debugging in order to activate the editor as an xDebug client.

Sweet!


Sources:

XDEBUG EXTENSION FOR PHP
http://xdebug.org/docs/remote

martomo / SublimeTextXdebug
https://github.com/martomo/SublimeTextXdebug

Package Control
https://sublime.wbond.net/installation#st2

Download:  Package Control.sublime-package
https://sublime.wbond.net/Package%20Control.sublime-package

Bannerad

Artikel Terpopuler

Tags

Blogumulus by Roy Tanck and Amanda Fazani