Uniform Server PHP IDE: IDE Overview: Difference between revisions

From The Uniform Server Wiki
Jump to navigation Jump to search
(New page: {{nav Uniform Server PHP IDE}} '''''PHP IDE Overview''''' Uniform Server PHP IDE ‘s main component is Notepad++ this is an excellent text editor and well supported. There is a wide rang...)
 
(Punctuation and grammatical changes; some clarification.)
 
Line 2: Line 2:
'''''PHP IDE Overview'''''
'''''PHP IDE Overview'''''


Uniform Server PHP IDE ‘s main component is Notepad++ this is an excellent text editor and well supported. There is a wide range of easily installed plugins for Notepad++ our IDE uses the following two plugings DBGp and NppExec. XDebug client DBGp interfaces to the PHP Debug module providing interactive control for debugging. An integrated console window and command scripting is provided by NppExec.
Notepad++ is Uniform Server PHP IDE‘s main component. This is an excellent text editor and is well supported. Notepad++ has a wide range of easily installed plugins. Our IDE uses the following two plugings DBGp and NppExec. The XDebug client DBGp interfaces to the PHP Debug module providing interactive control for debugging. An integrated console window and command scripting are provided by NppExec.


This overview covers the user interface, main debugging elements and menu options.
This overview covers the user interface, main debugging elements and menu options.
Line 11: Line 11:
|
|


IDE user interface consists of three windows:
The IDE user interface consists of three windows:


'''''Edit Window'':'''
'''''Edit Window'':'''
* Start IDE: Double click on file '''Run_IDE.bat'''
* Start IDE: Double click on file '''Run_IDE.bat'''
* Notepad++ runs and edit window is displayed. This is where you enter and save scripts.
* Notepad++ runs and the edit window is displayed. This is where you enter and save scripts.




'''''Debug Window'':'''  
'''''Debug Window'':'''  
* Click '''Debugger''' icon '''B)''' opens debug window
* Click '''Debugger''' icon '''B)''' to open the debug window
* Debug window '''DBGp''' displayed '''C)'''   
* Debug window '''DBGp''' displayed '''C)'''   




'''Console Window'''
'''Console Window'''
* Click '''Show Console Dialog''' icon '''D)''' opens console window
* Click '''Show Console Dialog''' icon '''D)''' to open the console window
* Console '''E)''' window displayed
* Console '''E)''' window displayed
|
|
Line 31: Line 31:
'''''Note'':'''
'''''Note'':'''


Resize and rearrange windows position as appropriate.
You can resize and rearrange windows position as appropriate.


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


== IDE Commands - Macro and Context menu ==
== IDE Commands - Macro and Context menu ==
IDE uses four command scripts these perform the following functions
IDE uses four command scripts that perform the following functions:
{| cellpadding="2" cellspacing="1" style="background:#000000;"
{| cellpadding="2" cellspacing="1" style="background:#000000;"
|-valign="top" style="background:#f5f5f5;"
|-valign="top" style="background:#f5f5f5;"
Line 45: Line 44:
| '''''C'')''' '''Run PHP CLI Debug'''  ||Execute currently displayed PHP script using the PHP interpreter configured for debugging. Debugging results displayed in debug window.  Script results displayed in console window.   
| '''''C'')''' '''Run PHP CLI Debug'''  ||Execute currently displayed PHP script using the PHP interpreter configured for debugging. Debugging results displayed in debug window.  Script results displayed in console window.   
|-valign="top" style="background:#f5f5f5;"
|-valign="top" style="background:#f5f5f5;"
| '''''D'')''' '''Run Script On Server'''  ||Run currently displayed PHP web page on server. Script is first saved and default browser redirected to page on server. Page displayed in browser.
| '''''D'')''' '''Run Script On Server'''  ||Run currently displayed PHP web page on server. Script is first saved and default browser redirected to page on server. Page is displayed in browser.
|}  
|}  


Line 70: Line 69:
|}
|}


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


== Debug Window Overview ==
== Debug Window Overview ==
At first sight the debugger looks intimidating however it really is easy to use. Start the IDE by running '''Run_IDE.bat'''
At first sight the debugger looks intimidating, however it really is easy to use. Start the IDE by running '''Run_IDE.bat'''
* Located in folder <whatever path you used>/'''us_portable_php_ide''' - Portable installation
* Located in folder <whatever path you used>/'''us_portable_php_ide''' - Portable installation
* Or located in folder <whatever path you used>/'''UniServer\us_portable_ide''' - Plugin installation
* Or located in folder <whatever path you used>/'''UniServer\us_portable_ide''' - Plugin installation
Line 87: Line 85:
* Set at least one break-point.
* Set at least one break-point.
** D) Click on a line becomes highlighted
** D) Click on a line becomes highlighted
** E) Click Add '''breakpoint button'''<br>''Marks line with a red dot''<br>''If clicked again toggles to off''  
** E) Click Add '''break point button'''<br>''Marks line with a red dot''<br>''If clicked again toggles to off''  
** F) Entry displayed in list<br>''Right click list to delete all breakpoints''
** F) Entry displayed in list<br>''Right click list to delete all breakpoints''
* G) From macro select '''Run PHP CLI Debug'''
* G) From macro select '''Run PHP CLI Debug'''
* Use the debugger toolbar or shortcut keys to control the debugger.
* Use the debugger toolbar or shortcut keys to control the debugger.
** H) Step Into - Proceed into functios
** H) Step Into - Proceed into functions
** I) Step over - Proceed
** I) Step over - Proceed
** J) Step out - If you're in a function, skip the rest and go to return.
** J) Step out - If you're in a function, skip the rest and go to return.
** K) Run to cursor - Automatically adds a break point runs script up to the cursor.
** K) Run to cursor - Automatically adds a break point and runs script up to the cursor.
** L) Run - Runs to next breakpoint or script end
** L) Run - Runs to next break point or script end
** M) End - Terminate debugging  
** M) End - Terminate debugging  
** O) Eval - Allows you to change a variable
** O) Eval - Allows you to change a variable


'''''Note'':''' Script output and errors are displayed in the cosole window
'''''Note'':''' Script output and errors are displayed in the console window
|
|
[[Image:Ide_debugging_1.gif]]
[[Image:Ide_debugging_1.gif]]
|}
|}


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


== Change Value of a variable ==
== Change Value of a variable ==
Line 114: Line 110:
=== Set a variable as follows ===
=== Set a variable as follows ===


* ''Step A)'' Click the '''Eval button''' this opens a pop-up
* ''Step A)'' Click the '''Eval button''' which opens a pop-up




* ''Step B)'' In the pop-up enter a '''variable name''' and assign a '''new value'''. For example '''$a=222'''<br>Note you do not need to add a semicolon.
* ''Step B)'' In the pop-up enter a '''variable name''' and assign a '''new value'''. For example '''$a=222'''<br>Note: you do not need to add a semicolon.
* ''Step C)'' Click '''OK''' this performs an evaluation and opens a pop-up   
* ''Step C)'' Click '''OK''' which performs an evaluation and opens a pop-up   




* ''Step D)'' Pop-up displays result of evaluation. Unlike PHP's eval new value is immediately available to your script.<br>Script may update this variable as it runs.
* ''Step D)'' Pop-up displays result of evaluation. Unlike PHP's eval, the new value is immediately available to your script.<br>Script may update this variable as it runs.
* ''Step E)'' Click cross to close pop-up window.   
* ''Step E)'' Click cross to close pop-up window.   
|
|
Line 127: Line 123:
|}
|}


'''''[[#top | Top]]'''''
== Watches ==
== Watches ==
List of variables displayed in the Local Context may become large masking a variable you want to constantly monitor.
The list of variables displayed in the Local Context may become large, obscuring a variable you want to constantly monitor.


Ideally you want to directly monitor a few variables this is achieved by using the Watches window. Add variables as appropriate to this window.
Ideally you want to directly monitor a few variables; this is achieved by using the Watches window. Add variables as appropriate to this window.
{|
{|
|-valign="top"
|-valign="top"
Line 137: Line 132:
=== Add Watch ===
=== Add Watch ===
* ''Step A)'' Click Watch tab (bottom of DBGp window)  
* ''Step A)'' Click Watch tab (bottom of DBGp window)  
* ''Step B)'' Right click in this window and select '''Add watch''' opens Add Watch pop-up     
* ''Step B)'' Right click in this window and select '''Add watch''' which opens Add Watch pop-up     
* ''Step C)'' In the pop-up enter variable to watch  
* ''Step C)'' In the pop-up enter variable to watch  
* ''Step D)'' Click '''OK''' adds variable to watch window
* ''Step D)'' Click '''OK''' adds variable to watch window
Line 149: Line 144:
|}
|}


'''''[[#top | Top]]'''''
== Xdebug Break function ==
== Xdebug Break function ==
For debugging you must set at least one break point. Currently we have a default break point set when the debugger starts. This is set to break on first line of a script.
For debugging you must set at least one break point. A default break point is set on first line of a script when the debugger starts.  


Generally this is suitable for most debugging applications however sometimes you want to start debugging in another page that is called from your main script.
This is suitable for most debugging applications, but sometimes you want to start debugging in another page that is called from your main script.


=== Disable default break point ===
=== Disable default break point ===
Line 168: Line 162:
'''''Note 1'':'''
'''''Note 1'':'''


For debugging to take place either manually set a break point in a page<br>or add the '''xdebug_break()''' function  
For debugging to take place, either manually set a break point in a page<br>or add the '''xdebug_break()''' function to the script.


|
|
Line 205: Line 199:
</pre>
</pre>
|}
|}
'''''[[#top | Top]]'''''
 
== Alternative Console Window ==
== Alternative Console Window ==
Notpad++’s integrated console window is ideal for running and testing scripts that use standard I/O. However being integrated there are limitations hence on occasions you may want to use a real command window (console cmd). This is achieved by running a batch file that in turn runs a PHP CLI script.
Notpad++’s integrated console window is ideal for running and testing scripts that use standard I/O. However being integrated there are limitations hence on occasions you may want to use a real command window (console cmd). This is achieved by running a batch file that in turn runs a PHP CLI script.
Line 232: Line 226:
|}
|}
=== Debug ===
=== Debug ===
The batch file runs our test script '''debug_test.php''' any output or input is directed to the batch file command window. The script is debugged using Notepad++ however in this scenario the internal console window is not used.
The batch file runs our test script '''debug_test.php''' and any output or input is directed to the batch file command window. The script is debugged using Notepad++ however in this scenario the internal console window is not used.


{|
{|
Line 250: Line 244:
[[Image:Ide_debugging_4.gif]]
[[Image:Ide_debugging_4.gif]]
|}
|}
'''''[[#top | Top]]'''''


== Summary ==
== Summary ==
Line 256: Line 249:


Next page looks at running [[Uniform Server PHP IDE: PHP CLI | PHP CLI scripts]] on this IDE.
Next page looks at running [[Uniform Server PHP IDE: PHP CLI | PHP CLI scripts]] on this IDE.
'''''[[#top | Top]]'''''


----
----

Latest revision as of 23:21, 9 December 2010

 

MPG UniCenter

Uniform Server PHP IDE.

PHP IDE Overview

Notepad++ is Uniform Server PHP IDE‘s main component. This is an excellent text editor and is well supported. Notepad++ has a wide range of easily installed plugins. Our IDE uses the following two plugings DBGp and NppExec. The XDebug client DBGp interfaces to the PHP Debug module providing interactive control for debugging. An integrated console window and command scripting are provided by NppExec.

This overview covers the user interface, main debugging elements and menu options.

IDE User interface

The IDE user interface consists of three windows:

Edit Window:

  • Start IDE: Double click on file Run_IDE.bat
  • Notepad++ runs and the edit window is displayed. This is where you enter and save scripts.


Debug Window:

  • Click Debugger icon B) to open the debug window
  • Debug window DBGp displayed C)


Console Window

  • Click Show Console Dialog icon D) to open the console window
  • Console E) window displayed

Note:

You can resize and rearrange windows position as appropriate.


IDE Commands - Macro and Context menu

IDE uses four command scripts that perform the following functions:

A) Check PHP Syntax Check syntax of currently displayed PHP script in edit window. Results are displayed in console window. Double clicking on any highlighted errors scrolls the edit window and highlights corresponding line in error.
B) Run as PHP CLI Execute currently displayed PHP script using the PHP interpreter. Results displayed in console window.
C) Run PHP CLI Debug Execute currently displayed PHP script using the PHP interpreter configured for debugging. Debugging results displayed in debug window. Script results displayed in console window.
D) Run Script On Server  Run currently displayed PHP web page on server. Script is first saved and default browser redirected to page on server. Page is displayed in browser.

Command scripts are run using either the macro drop-down menu or context menu shown below:

Context menu:

  • Right click in edit window
  • Context menu displayed
  • Entries A-D

   

Macro drop-down menu:

  • Click Macro
  • Corresponding entries displayed
  • Entries A-D


Debug Window Overview

At first sight the debugger looks intimidating, however it really is easy to use. Start the IDE by running Run_IDE.bat

  • Located in folder <whatever path you used>/us_portable_php_ide - Portable installation
  • Or located in folder <whatever path you used>/UniServer\us_portable_ide - Plugin installation

Open test file debug_test.php (contained in folder php_scripts) in Notepad++ edit window and follow the instructions below to debug.

  • Start Notepad++.
  • A) Click to show debugger window
  • B) Click to show console window
  • C) Open a script file to be debugged (debug_test.php).
  • Set at least one break-point.
    • D) Click on a line becomes highlighted
    • E) Click Add break point button
      Marks line with a red dot
      If clicked again toggles to off
    • F) Entry displayed in list
      Right click list to delete all breakpoints
  • G) From macro select Run PHP CLI Debug
  • Use the debugger toolbar or shortcut keys to control the debugger.
    • H) Step Into - Proceed into functions
    • I) Step over - Proceed
    • J) Step out - If you're in a function, skip the rest and go to return.
    • K) Run to cursor - Automatically adds a break point and runs script up to the cursor.
    • L) Run - Runs to next break point or script end
    • M) End - Terminate debugging
    • O) Eval - Allows you to change a variable

Note: Script output and errors are displayed in the console window


Change Value of a variable

After running up to a break-point and before continuing you may want to change a variable’s value.

Set a variable as follows

  • Step A) Click the Eval button which opens a pop-up


  • Step B) In the pop-up enter a variable name and assign a new value. For example $a=222
    Note: you do not need to add a semicolon.
  • Step C) Click OK which performs an evaluation and opens a pop-up


  • Step D) Pop-up displays result of evaluation. Unlike PHP's eval, the new value is immediately available to your script.
    Script may update this variable as it runs.
  • Step E) Click cross to close pop-up window.

Watches

The list of variables displayed in the Local Context may become large, obscuring a variable you want to constantly monitor.

Ideally you want to directly monitor a few variables; this is achieved by using the Watches window. Add variables as appropriate to this window.

Add Watch

  • Step A) Click Watch tab (bottom of DBGp window)
  • Step B) Right click in this window and select Add watch which opens Add Watch pop-up
  • Step C) In the pop-up enter variable to watch
  • Step D) Click OK adds variable to watch window


Delete Watch

  • Right click on watch variable to delete
  • Select Delete

Xdebug Break function

For debugging you must set at least one break point. A default break point is set on first line of a script when the debugger starts.

This is suitable for most debugging applications, but sometimes you want to start debugging in another page that is called from your main script.

Disable default break point

How to disable

  • Open DBGp configuration window Plugins>DBGp>Config...
  • Step D) Un-Check Break at first line when debugging starts
    • Leave all other settings as they are
  • Step E) Click OK


Note 1:

For debugging to take place, either manually set a break point in a page
or add the xdebug_break() function to the script.

Add xdebug_break() to a page

You can add the xdebug_break() to any location in a page and break at that point

For example

  • Modify test script debug_test.php as shown on right
  • Start debugger
  • From macro select Run PHP CLI Debug
  • Notepad++ icon flashes
  • Green arrow points to line 6 xdebug_break()

Note:

No variables displayed in local context window.
To gather the debug information you need to step
the debugger one position using Step Into button.

<?php
$a=10;
$b=20;
$c=$a+$b;
print "Result = $c\n";
xdebug_break() ;
print "Debug Test $a\n";
print "Debug Test $b\n";
?>

Alternative Console Window

Notpad++’s integrated console window is ideal for running and testing scripts that use standard I/O. However being integrated there are limitations hence on occasions you may want to use a real command window (console cmd). This is achieved by running a batch file that in turn runs a PHP CLI script.

Following demonstrates this technique using our test script debug_test.php

Batch file

  • For example create a new batch file debug.bat
  • Content shown on right
  • Save to folder php_scripts
mode con:cols=65 lines=20
TITLE UNIFORM SERVER - Debug Test
COLOR B0
@echo off
cls

..\unicode\php\php.exe -c ..\unicode\php\php_cli_ide_debug.ini debug_test.php

pause

Debug

The batch file runs our test script debug_test.php and any output or input is directed to the batch file command window. The script is debugged using Notepad++ however in this scenario the internal console window is not used.

  • Start Notepad++.
  • Show debugger window (click its icon) No need to open test script.
  • Navigate to folder php_scripts
  • Run batch file debug.bat (double click on it)
  • Blank command window opens
  • Notepad++ tray icon flashes.
  • Script is loaded into edit window
  • Debug window is ready for debugging.
  • Run and debug.
  • A complete run is shown on right

Summary

The above has shown how to install the Uniform Server IDE.

Next page looks at running PHP CLI scripts on this IDE.