Understanding the architecture
The diagram below shows the main IPC (inter process communications) mechanisms implemented by Dev-PHP in order to debug, or simply to execute scripts. Dev-PHP is providing only the blue boxes. Other boxes are easily installed by PiGii.
A human being may also interact through such things as the Editor, the Toolbar and the Browser. The Editor is used to manage breakpoints and variables ; the debug Toolbar controls all that matters for executing PHP scripts ; and the Browser... is intended for end-users.
Install a PHP engine
Connect a PHP engine to Dev-PHP
|Actually, Dev-PHP needs to know where the file named php-cgi.exe is. "cgi" stands for Common Gateway Interface.
From the Options form (Menu Options -> General Options...), select the item Project and enter the full filename directly. Alternatively, you can click on the speed button at the right side of the edit box, in order to browse directories and then select that file.
Afterwards, record the changes by clicking the "Ok" button.
Check the proper functioning
|Well, enter the following little script in Editor
<?php $myIndex = 12; $myDebug = debug_backtrace(); phpinfo(); ?>
|Then perform one of the following actions, at your choice
Whatever the action, you should see a display of PHP version and a lot of valuable information about ready to use features.
What could go wrong here?
The frequently asked questions
Going a little further... with Xdebug
Set a breakpoint
|From the Editor tab sheet, click on the left part of the gutter in front of the line containing phpinfo().
The gutter is the greyed area where line numbers are displayed. If line numbers are hidden, then make them visible via Menu "View -> Line numbers".
Et voilà, you have just set your first breakpoint.
More information on how to set, get, remove and save breakpoints can be found on Manage breakpoints.
Start an Xdebug session
|The debug toolbar should be visible (Menu View -> Messages). Here, we have two paths. The first one starts from the internal browser and the other one starts form an external browser.|
Using the "Internal Browser"
|Choose one of the three methods below:
A few seconds later, the yellow lamp switches off and other icons are switched on. Some lines in xml format, are written to the "Debugger log" tab sheet, corresponding to the responses of Xdebug. Xdebug is waiting for orders.
|Ladies and Gentlemen, it is time to click on the "Run" icon, from the Debug toobar, (the shortcut is F5)
Several micro-seconds later, may be more, a green triangle with a pretty yellow border appears on the gutter. This is the marker for the execution point.
Now, the status of the debugger is "Break". Once again, the debugger is waiting for your orders.
|At this point, the "Evaluation" tab sheet has been automatically updated. Here, Dev-PHP displays only a set of variables you've previously selected. This set is saved whenever you select menu "Project -> Save Project...", and it is restored on "Project -> Open Project..." or "Project -> Recently used -> ".
Evaluation can take a long time to display, that is why a check box is associated to each variable. At this point, you may wish to add or delete some variables via a right click.
Furthermore, it is possible to change the value of a variable, on the fly.
|The "Context" tab sheet is not automatically fed with all the local vars. It is refreshed via the "Eval" icon from debug toolbar. "Context" is dockable, this means that you can undock it and move it elsewhere - above Dev-PHP or even outside Dev-PHP.
By design, "Context" goes very fast to execute.
Other icons are common ones (step into, step over and step out).
By the way... Press <F5> !
A few milliseconds later, the yellow lamp switches on and other icons are switched off.
This is the end of the show.
I know that you're very impressed:
- "Oh my God, what a wonderful program it is! what a wonderful program it is!"
And I know that you're wondering:
- "Where on earth are the outputs?"
|Well, actually the "Internal Preview" tab sheet contains a "Dev-PHP - Preview" panel... which is dockable. Next time, start by undocking this panel then continue with the debug toolbar.|
Using an external browser
We are going to use a small sequence of keys to ensure that the server side of Xdebug is listening. This has to be done only once.
From Dev-PHP, hit <Ctrl+F5> then <Ctrl+Break>
As we have already seen ( Architecture), Dev-PHP is coming with an internal web server. It is serving connections on port 8888 by default.
Since we do not have the equivalent of Aladdin lamp for invoking our genius Xdebug, we will build roughly a switch. That is the role given to XDEBUG_SESSION_START=devphp
I suddenly realize that this sounds more like Ali Baba and the forty thieves.
Don't worry, say to firefox http://localhost:8888/index.php?XDEBUG_SESSION_START=devphp
Look at the debug toolbar: the yellow lamp is off, other icons are on, so go ahead!Remember the words to open your treasure cave, "Open, Simsim" is another story.