Skip to end of metadata
Go to start of metadata

Here is a simple sample of using PHP Development Tools (PDT - the PHP programing plugin for Eclipse) on Fedora 7.

(For detail information on how to install PDT for Eclipse in Fedora 7 and CentOS 5, please visit:
Installing PHP Development Tools on Fedora 7
Installing PDT and PHPEclipses on CentOS)

Please note that

Icon

In this example, I logged in as "zhaonx" and "\home\zhaonx\" is my home direcotry.

Start Eclipse

Start a terminal window; then go into the directory where Eclipse is installed (unpacked from tar ball); and then start eclipse.

Create a menu item for Eclipse

Icon

You can create a menu item for Eclipse, then you do not need to do the above step.

Create a new PHP project

  • When Eclipse is staring, a "workspace launcher" window will appear and ask to select a workspace (Figure 1). You can click "Ok" to create a default workspace in your home directory or you can select a workspace you've created by clicking "Browse...".
    Unknown macro: {html}

    <DIV align="center">Figure 1: Select workspce</DIV><BR></BR>

  • Click "File->New->Project...", a "New Project" window will appear (see Figure 2). Double click the line "PHP" and select "PHP Project", then click "Next". A "PHP Project" window will appear (see Figure 3). Give a project name, and then click "Finish". Eclipse will ask to open associated perspective, click "Yes".
    Unknown macro: {html}

    <DIV align="center">Figure 2: Select New Project window</DIV><BR></BR>


Unknown macro: {html}

<DIV align="center">Figure 3: New PHP Project Window</DIV><BR></BR>

Add PHP File in your PHP project

After you create a PHP project, you need to add PHP file into your project.


Unknown macro: {html}

<DIV align="center">Figure 4: PHP project working space window</DIV><BR></BR>

In the above PHP project working space window, right click on "test" in PHP Explorer window, then in the pop-up menu, click "New->PHP File". (Figure 5)

Unknown macro: {html}

<DIV align="center">Figure 5: Pop-out menu</DIV><BR></BR>

In the "New PHP File" window, give a name for the new PHP file, and click "Finish". A new PHP file will be created (in my case, index.php) and will be open in PHP Project working space. It should looks link Figure 6. Add code in this opened php file and save the file.

Unknown macro: {html}

<DIV align="center">Figure 6: Index.php file is opened</DIV><BR></BR>

Debug PHP file

Set a break point in your simple PHP file. There are several ways to do so. One way is double click the space before the line number of the line you want to set breakpoint. Another way is to click the line you want to set breakpoint, and then click menu "Run" and select "Toggle Breakpoint" to set or unset breakpoint.

Unknown macro: {html}

<DIV align="center">Figure 7: Set breakpoint</DIV><BR></BR>

There are two types of debugging. One is debugging as "PHP Script" and another is debugging as "PHP Web Page". To debug as "PHP Script", click "Run->Debug as->PHP Script", Eclips system will ask to open PHP debug perspective. Click "yes" to open the proper perspective.

Unknown macro: {html}

<DIV align="center">Figure 8: Debug as PHP Script</DIV><BR></BR>

To debug as "PHP Web page", click "Run->Debug as->PHP Web Page". You need to set the URL for your web browser to launch the PHP web page. To ensure the URL is accessible, you need to edit your http configuration file (in \etc\httpd\conf on Fedora 7) to set a alias or directory for the project you've created. For example, in my case, I need to set directory "/home/zhaonx/workspace2/test" accessible to web browser; and I want to use "http://localhost/test/" as the URL to debug my test.php file. I need to add the following code in my \etc\httpd\conf\httpd.conf file.

  • No labels