Tek Eye Logo

Tek Eye

Developing PHP on Windows with Eclipse PDT

This article covers installing the Eclipse PDT tools to allow for PHP development on Windows. What is Eclipse PDT? PDT stands for PHP Development Tools. Eclipse PDT is a version of the Eclipse Integrated Development Enivironment (IDE) for PHP use. (An IDE is an all in one program for writing, running and debugging code). The Eclipse PDT is used to develop PHP applications for deployment on web servers. (PHP can be used to write scripts on normal PCs, though rarely, as PHP is popular for web based applications).

PHP logo

In this article:

  • What is PHP?
  • Determine if your version of Windows is 32-bit or 64-bit
  • Download and install Java, which is needed to run the Eclipse IDE
  • Install PHP for Windows using Microsoft's Web Platform Installer
  • Download and install the Eclipse PDT
  • Test writing and running PHP code on Windows

Notes:

  • Setting up a PHP development environment using the Eclipse PDT requires a lot of software downloading, therefore a good Internet connection is required.
  • You will be installing software on Windows, therefore you need to have Administrator rights to the Windows machine.

What is PHP?

PHP is a commonly used computer language used for developing websites and web based applications. It has been around since the early days of the World Wide Web when PHP originally stood for Personal Home Page, see PHP on Wikipedia for the history. PHP now stands for PHP: Hypertext Preprocessor. Since web pages are made up of hypertext, indeed HTML stands for HyperText Markup Language, the PHP program will processor PHP code to produce HTML and send it to the users web browser.

How to Check if 32 or 64 Bit Windows is on Your PC

When you download software you sometimes need to chose a package for either 32-bit or 64-bit version of Windows. If you are unsure whether you are running 32-bit or 64-bit Windows use the System option in Windows to find the System type:

  • Windows 10 - Select Settings (the gear icon) then System. Select About and read the System type line.
  • Windows 8.1 - System type can be accessed via PC info from the settings icon on the charm bar.
  • Other versions of Windows - Via System and Security from Control Panel, under Basic Information.

Download and Install Java to Run Eclipse

The Eclipse IDE is built with Java. To install Java download the latest Java version from the Java SE Downloads page. You may need to add the path to the Java bin directory using the Environment Variables option in System Properties.

For full details see the Tek Eye article Installing Java on Windows (32-Bit or 64 Bit)

Install PHP for Windows

The easiest way to install PHP onto a Windows computer is use Microsoft's WebPI, for Web Platform Installer. Once WebPI is installed run the WebPI app to install PHP and the Windows IIS WebServer. For full details see the Tek Eye article Install PHP on Windows with Web Platform Installer.

To check that the IIS Webserver installed correctly enter localhost in the browser's address bar.

IIS Webserver

A PHP Development Environment on Windows

To use Eclipse PDT on Windows grab the installer from the PDT home page.

PHP on Windows

Scroll down to the Download section and chose the button for you Operating System (OS). Click the Download button when shown and save the zip file to your system. Copy the folder in the zip download to your computer's disk, e.g. to C:\ or any suitable location.

Copy Eclipse PDT

In the Eclipse folder run eclipse.exe. For future ease of access use the context menu (usually right-click) to create a shortcut to eclipse.exe or pin it to the Taskbar. Eclipse will ask for the workspace to be set, this is the default place to create new projects. When prompted with the Windows Security Alert also provide Eclipse with access through the Windows Defender Firewall by clicking Allow Access.

Eclipse Set Workspace

Check Developing PHP on Windows Works

To check that PHP development on Windows works create a new project and setup a IIS website for it. With Eclipse running create a new PHP project and give it a name, e.g. php-test.

Eclipse New PHP Project

Create a new PHP file.

New PHP FIle in Eclipse

And give it a name, e.g. php-test.php

Name a PHP File in Eclipse

Edit the new file to use the phpinfo() function to output some PHP configuration information.

<?php
phpinfo();
?>

Save the file.

Create a Website in IIS for the PHP Project

To create a website for the PHP project run the IIS Manager app. It will need to be run under an administrator account.

Manage PHP website in IIS

In IIS Manager use the context menu to choose Add Website.

Add IIS Website

Give the site a name and point it to the PHP project directory. Also ensure that IIS has access to the project folder, set the username and password for a user with permissions to the project folder. This can be the administrator account if required. Use the Test Connection option to ensure IIS can access the project files.

Add User to IIS Website

Use a different Internet port binding to prevent conflict with the default port 80, e.g. here port 8000 is used:

IIS Port Binding

Run the PHP Project

On first press of the Play icon in Eclipse configure the PHP Web Application.

Configure PHP Server

Enter the server settings for the project, here the port binding is included in the URL.

PHP Server in Eclipse

The Eclipse project properties, accessible from the Project menu, or context, menu can be used to edit the webserver configuration information when required. Here the project folder is not required in the URL because IIS is already configured to serve the files from the project folder. I.e. the project folder is the IIS virtual folder for the php-test website.

Eclipse PHP Server Config

All being well pressing the Play icon should execute the php-test.php file and serve the PHP information to the browser in Eclipse:

PHP in Eclipse

Using the Express Version of IIS

Instead of using the full version of Microsoft IIS for testing PHP websites, the Express version of IIS can be used. IIS Express can also be installed using the Web Platform app. If using the Express version of IIS starting the webserver is a different process. The IIS Express webserver will need to be started from the Windows command line. Start by opening a command line under an administrator account.

Administrator Command Terminal

Change directory to the PHP project folder and run the command runphp.cmd. The WebPI app should have added the path to the PHP folder containing the command file.

Run IIS for PHP

The command box is kept open to allow IIS to be closed when the development session is finished.

Starting IIS Express

The runphp.cmd command file uses port 8080 by default.

IIS Express for PHP Websites

Optionally Install a PHP Debugger

A popular PHP debugger is Xdebug. Go to the Xdebug download page and choose the version that matches the PHP version you are using. Use the phpinfo information to check the PHP version if required. Copy the Xdebug file into the PHP ext directory. Administrator permissions will be required. Edit the php.ini file to add the following lines (replacing PATH TO PHP EXT\XDEBUG DLL NAME with your actual path and name of the Xdebug file:

zend_extension="PATH TO PHP EXT\XDEBUG DLL NAME"
xdebug.remote_enable=1

E.g.:

zend_extension = "C:\Program Files\PHP\v7.2\ext\php_xdebug-2.6.1-7.2-vc15-nts-x86_64.dll"
xdebug.remote_enable=1

Close any browser windows to ensure that Xdebug will load when the website is started again. Use the Eclipse Preferences from the Window menu to ensure that the PHP server settings are updated for Xdebug.

Xdebug in Eclipse

Running a project from the bug icon allows code stepping and watching of variable values.

Eclipse PHP Debugging

To use a web browser external to Eclipse change the Web Browser settings under Preferences and General.

Eclipse web browser setting

Setting up PHP development on Windows is a little involved, but Eclipse can help with writing and debugging PHP based web apps.

See Also

Author:  Published:  

ShareSubmit to TwitterSubmit to FacebookSubmit to LinkedInSubmit to redditPrint Page

Do you have a question or comment about this article?

(Alternatively, use the email address at the bottom of the web page.)

 This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

markdown CMS Small Logo Icon ↓markdown↓ CMS is fast and simple. Build websites quickly and publish easily. For beginner to expert.


Articles on:

Android Programming and Android Practice Projects, HTML, VPS, Computing, IT, Computer History, ↓markdown↓ CMS, C# Programming, Using Windows for Programming


Free Android Projects and Samples:

Android Examples, Android List Examples, Android UI Examples



Tek Eye Published Projects