Dev-PHP2.ug:web

From Dev-PHP
Jump to: navigation, search

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.

The main IPC inside Dev-PHP

Xdebuguses port 9000, and the internal web server works via port 8888.
The PHPengine is ordered thru pipes and environment variables.
All other communications are based on messages (not shown).

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

Even if you already have a PHP engine, PiGii (preferably the standard version) is a good choice because it installs a fully functional environment, including Xdebug and its parameters.

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.
Tip: Storing the php.ini into the project folder is generally a good idea considering the integrity of the project, especially in terms of backup and restoration.

Afterwards, record the changes by clicking the "Ok" button.

Connect a PHP engine

Check the proper functioning

Well, enter the following little script in Editor
<?php
    $myIndex = 12;
    $myDebug = debug_backtrace();
    
    phpinfo();
?>
First script
The first run is nice
Then perform one of the following actions, at your choice
  1. Menu Run -> Run PHP Script
  2. Click on "Internal Preview" tab
  3. Hit <Shift+F5>, although <F5> might also work

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

If you did not download and install PiGii, then you have to install and set up Xdebug by hand: see Manually installing the Debugger

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".

After clicking the gutter, a form will appear. Select the radio button "unconditional" then press the "Set" button.

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.

First breakpoint

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.
Debug: ready to go!

Using the "Internal Browser"

Choose one of the three methods below:
  1. Hit <Ctrl+Shift+F5>, although <Ctrl+F5> might also be working
  2. or, Hold down the <Ctrl> key *and* click on Menu "Run -> Run PHP Script"
  3. or, Click on the yellow lamp from the Debug toolbar

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.

Debug: started!
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.

Debug: the break status
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.

Debug: the Evaluation tab sheet
Debug: changing a value
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).

Debug: "Context" tab sheet

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.
Debug: undocked panels
Debug: end of show

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>

Debugging from an external browser is a good choice. That decreases the workload of Dev-PHP, and, mainly, allows you to debug javascript more conveniently - have a look to that wonderful Firefox Add-ons called Firebug.<p>

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.