Uniform Server PHP IDE: XDebug Overview: Difference between revisions

From The Uniform Server Wiki
Jump to navigation Jump to search
(New page: {{nav Uniform Server PHP IDE}} '''''XDebug Overview''''' XDebug is a main building block of the Uniform Server PHP IDE. XDebug along with Notepad++’s debugging client provides debugging...)
 
(Punctuation and grammatical changes; some clarification and additional explanation. Also fixed images to show port 9000.)
Line 4: Line 4:
XDebug is a main building block of the Uniform Server PHP IDE. XDebug along with Notepad++’s debugging client provides debugging capabilities for both CLI scripts and Web Page scripts.
XDebug is a main building block of the Uniform Server PHP IDE. XDebug along with Notepad++’s debugging client provides debugging capabilities for both CLI scripts and Web Page scripts.


XDebug’s versatility allows it to run on a server or from a command line. Debugging architecture differs slightly this page provides an overview of these different architectures.
XDebug’s versatility allows it to run on a server or from a command line. The debugging architecture differs slightly and this page provides an overview of these different architectures.


== PHP CLI Debugging ==
== PHP CLI Debugging ==
Line 16: Line 16:
'''Sequence of events'''
'''Sequence of events'''
* Step A) Run Notepad++.
* Step A) Run Notepad++.
* Step B) Start Notepad++'s client (DBGp plugin) this opens socket 9000<br>(listens on port 9000)
* Step B) Start Notepad++'s client (DBGp plugin) which opens socket 9000<br>(listens on port 9000)
* Step C) Run script from Notepad++ (Executes PHP interpreter).
* Step C) Run script from Notepad++ (Executes PHP interpreter).
* Step D) Interpreter loads configuration file and loads extensions (php_xdebug.dll)
* Step D) Interpreter loads configuration file and loads extensions (php_xdebug.dll)
Line 29: Line 29:




'''''Note 2'':''' If the script is initiated from an external source (for example a batch file) XDebug determines if the script (F) is displayed in Notepad++ if not downloads it.
'''''Note 2'':''' If the script is initiated from an external source (for example, a batch file) XDebug determines if the script (F) is displayed in Notepad++. If not, it is downloaded.




'''''Note 3'':''' If XDebug starts debugging a new page that page is download if not already displayed in Notepad++.
'''''Note 3'':''' If XDebug starts debugging a new page, that page is downloaded if not already displayed in Notepad++.
|
|
[[Image:Ide_xdebug_1.gif]]
[[Image:Ide_xdebug_1.gif]]
|}
|}
'''''[[#top | Top]]'''''


== Web Page Debugging ==
== Web Page Debugging ==
Debugging a website running on a local server requires effectively a second server and client. This second sever and client taps into the prime server and web site providing debugging and control of that site and server.
Debugging a website running on a local server effectively requires a second server and client. This second server and client taps into the primary server and web site to provide debugging and control of that site and server.


The second server is created using a PHP extension (php_xdebug.dll) it seamlessly installs code to provide communication between Apache and a client (Notepad++ with DBGpplugin installed) over port 9000. In addition code is installed to monitor browser requests arriving on the standard Apache port 80.   
The second server is created using a PHP extension (php_xdebug.dll). It seamlessly installs code to provide communication between Apache and a client (Notepad++ with DBGpplugin installed) over port 9000. In addition, code is installed to monitor browser requests arriving on the standard Apache port 80.   
{|
{|
|-
|-
Line 61: Line 60:


* Step I) User uses client for debugging. Commands and data are sent over port 9000
* Step I) User uses client for debugging. Commands and data are sent over port 9000
* Step J) Client can instruct XDebug to execute one or more php statements. Your PHP code is executed this may output data over http Port (80) to web browser.
* Step J) Client can instruct XDebug to execute one or more php statements. Your PHP code is executed; this may output data over http Port (80) to web browser.




Line 69: Line 68:
[[Image:Ide_xdebug_2.gif]]
[[Image:Ide_xdebug_2.gif]]
|}
|}
'''''Note 1'':''' Debugging is initiated from a browser. XDebug determines if the page is displayed in Notepad++ if not downloads it.
'''''Note 1'':''' Debugging is initiated from a browser. XDebug determines if the page is displayed in Notepad++ and if not, it is downloaded.


'''''Note 2'':''' If XDebug starts debugging a new age that page is download if not already displayed in Notepad++.
'''''Note 2'':''' If XDebug starts debugging a new page, which is downloaded if not already displayed in Notepad++.


'''''Note 3'':''' During debugging browser shows page loading
'''''Note 3'':''' During debugging, the browser shows page loading


'''''Note 4'':''' After step A) you can directly load, edit and save the page to be debugged. After enabling the debug client at step B) you can set breaks points and then imitate a debug session via the browser Step C. Next page covers this in more details.
'''''Note 4'':''' After step A) you can directly load, edit and save the page to be debugged. After enabling the debug client at step B) you can set breaks points and then imitate a debug session via the browser Step C. Next page covers this in more details.


'''''[[#top | Top]]'''''


== Summary ==
== Summary ==
Above block diagrams show commonality between the two architectures essentially they are the same. Each uses Notepadd++’s client plugin for debugging this is covered in detail on the [[Uniform Server PHP IDE: IDE Overview | next page]].
The above block diagrams show the commonality between the two architectures which are essentially the same. Each uses Notepadd++’s client plugin for debugging. This is covered in detail on the [[Uniform Server PHP IDE: IDE Overview | next page]].


'''''[[#top | Top]]'''''


----
----

Revision as of 07:40, 9 December 2010

 

MPG UniCenter

Uniform Server PHP IDE.

XDebug Overview

XDebug is a main building block of the Uniform Server PHP IDE. XDebug along with Notepad++’s debugging client provides debugging capabilities for both CLI scripts and Web Page scripts.

XDebug’s versatility allows it to run on a server or from a command line. The debugging architecture differs slightly and this page provides an overview of these different architectures.

PHP CLI Debugging

Debugging a PHP CLI script requires control of the PHP interpreter and a mechanism to separate script flow and error messages generated. A debugging client must provide unobtrusive communication with the interpreter while allowing a script to run.

The PHP extension php_xdebug.dll seamlessly installs code to provide interpreter control and communication between a client (Notepad++ with DBGp plugin installed in the IDE) and the PHP interpreter over port 9000. Effectively php_xdebug.dll includes a mini server to provide communication with a client.

Sequence of events

  • Step A) Run Notepad++.
  • Step B) Start Notepad++'s client (DBGp plugin) which opens socket 9000
    (listens on port 9000)
  • Step C) Run script from Notepad++ (Executes PHP interpreter).
  • Step D) Interpreter loads configuration file and loads extensions (php_xdebug.dll)


  • Step E) XDebug establishes contact with client.
  • Step F) Script is loaded and run.
  • Step G) Script execution (debugging) is controlled by client.


Note 1: Debugging is initiated as soon as the interpreter loads XDebug.


Note 2: If the script is initiated from an external source (for example, a batch file) XDebug determines if the script (F) is displayed in Notepad++. If not, it is downloaded.


Note 3: If XDebug starts debugging a new page, that page is downloaded if not already displayed in Notepad++.

Web Page Debugging

Debugging a website running on a local server effectively requires a second server and client. This second server and client taps into the primary server and web site to provide debugging and control of that site and server.

The second server is created using a PHP extension (php_xdebug.dll). It seamlessly installs code to provide communication between Apache and a client (Notepad++ with DBGpplugin installed) over port 9000. In addition, code is installed to monitor browser requests arriving on the standard Apache port 80.

Sequence of events

Assumes Uniform Server running (Apache server running).

  • Step A) Start Notepad++.
  • Step B) Notepad++'s client DBGp plugin opens socket 9000 (listens on port 9000)
  • Step C) In a browser enter address of PHP page to be debugged.
  • Step D) Browser requests this page from Apache server over port 80
  • Step E) Apache runs the PHP interpreter
  • Step F) PHP interpreter runs its extensions including the XDebug module.


  • Step G) XDebug module starts remote debugging.
  • Step H) XDebug connects to debugging client over port 9000


  • Step I) User uses client for debugging. Commands and data are sent over port 9000
  • Step J) Client can instruct XDebug to execute one or more php statements. Your PHP code is executed; this may output data over http Port (80) to web browser.


  • Step K) When all your PHP code has been executed, XDdebug disconnects from client.
  • Step L) Followed by Apache closing connection to browser.

Note 1: Debugging is initiated from a browser. XDebug determines if the page is displayed in Notepad++ and if not, it is downloaded.

Note 2: If XDebug starts debugging a new page, which is downloaded if not already displayed in Notepad++.

Note 3: During debugging, the browser shows page loading

Note 4: After step A) you can directly load, edit and save the page to be debugged. After enabling the debug client at step B) you can set breaks points and then imitate a debug session via the browser Step C. Next page covers this in more details.


Summary

The above block diagrams show the commonality between the two architectures which are essentially the same. Each uses Notepadd++’s client plugin for debugging. This is covered in detail on the next page.