How To Install Eclipse for PHP on Ubuntu

PHP
By bhagwatchouhan
How To Install Eclipse for PHP on Ubuntu

In this tutorial, we will discuss the steps required to install the most recent release of Eclipse (Eclipse 2019) for PHP on the popular Linux distribution Ubuntu. It provides the steps for Ubuntu 18.04 LTS. The steps should be the same for other versions of Ubuntu and Linux based systems. It assumes that PHP and Java are already installed on the system.

Notes: You may follow How To Install Java 10 On Ubuntu, How To Install Java 11 On Ubuntu, and How To Install OpenJDK 12 On Ubuntu to install Java on Ubuntu 18.04 LTS. I have installed OpenJDK 12 for this tutorial. You can also follow How To Install PHP 7 On Ubuntu 18.04 LTS to install PHP 7 on Ubuntu 18.04 LTS.

 

Download Eclipse for PHP

Open the Eclipse Packages page. It will show the options to download Eclipse IDE for PHP Developers as shown in Fig 1. The Eclipse IDE for PHP Developers is pre-configured for PHP development. It also comes with the web development tools and plugins required for HTML, CSS, and JavaScript.

Download Eclipse

Fig 1

Now click Linux 64 Bit link as highlighted in Fig 1. It will show the download options from mirror sites as shown in Fig 2.

Eclipse Download Mirror

Fig 2

Click on the Download Button to start the download.

 

Confirm PHP and Java

In this step, we will confirm whether PHP and Java are already installed on the system. You can also follow the links mentioned at the start of this tutorial to install missing PHP and Java on Ubuntu.

# Test PHP version
php --version
# It will show the PHP installed on the system PHP 7.2.19-0ubuntu0.18.04.1 (cli) (built: Jun 4 2019 14:48:12) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.19-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
# Test Java version java --version
# It will show the Java installed on the system openjdk 12.0.1 2019-04-16 OpenJDK Runtime Environment (build 12.0.1+12) OpenJDK 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing

I have installed the most recent version of PHP 7.2 and OpenJDK as shown above.

 

Install Eclipse for PHP

In this step, we will install Eclipse for PHP as downloaded by us in the previous step.

Extract the Eclipse file downloaded by us. It should be similar to the one as shown in Fig 3.

Extract Eclipse

Fig 3

We can either directly execute the executable file as highlighted in Fig 3 or create a desktop icon by following the next step.

 

Create Desktop Shortcut

In this step, we will install the GNOME panel and use the same to create a desktop shortcut to execute the Eclipse installed by us in previous steps.

# Install GNOME Panel
sudo apt-get install --no-install-recommends gnome-panel
# Create Desktop icon gnome-desktop-item-edit ~/Desktop/ --create-new

Now configure the Eclipse installation as shown in Fig 4. We will use the Eclipse icon available in the root of the installation directory.

Destop Shortcut

Fig 4

Provide name and description of the shortcut as shown in Fig 4. Now click on the Browse Button and navigate to the installation directory of the Eclipse. Choose the executable file as the command option as shown in Fig 4.

Press the OK Button to create the shortcut. The above-mentioned commands will create a desktop shortcut icon so that we can execute Eclipse without navigating to the installation directory. It might ask for security permission for the first time when you will execute Eclipse using the desktop launcher icon.

 

Execute Eclipse and Configure Workspace

In this step, we will execute the Eclipse and configure the workspace. A workspace is a collection of projects and arrangement of the development IDE.

Start Eclipse by either clicking the executable file from installation path or the desktop shortcut icon created by us. It will show the splash screen and show the dialog to choose workspace as shown in Fig 5.

Configure Workspace

Fig 5

Make sure that you have kept the checkbox to choose workspace at start of Eclipse as unchecked so that we can select a different workspace at the start of Eclipse.

Now click on the Launch Button to launch the Eclipse IDE with the selected workspace. It should look similar to the one as shown in Fig 6.

Welcome Screen

Fig 6

We can also uncheck the checkbox (Always show Welcome at start up) to hide the welcome screen at the start of Eclipse. It will show the default workspace for PHP development as shown in Fig 7 on hiding the welcome screen.

PHP Worspace

Fig 7

 

Hello PHP

In this step, we will create our first PHP project using Eclipse and print Hello PHP on the console.

Click on File -> New -> PHP Project to create a PHP project in Eclipse. It will show the project configuration dialog as shown in Fig 8. We can either create the project at the workspace location or it can be some other location having all the existing PHP projects. I have also selected the PHP version 7.2 as shown in Fig 8.

Create PHP Project in Eclipse

Fig 8

Click the Finish Button to finalize and create the project within the active workspace.

Now right click on the Project -> New -> PHP File in order to create a PHP file. It will show the File Wizard as shown in Fig 9.

Create PHP File

Fig 9

Provide the appropriate name of the PHP file and click the Finish Button to create the file as shown in Fig 9.

Now update the PHP file to echo Hello PHP as shown in Fig 10.

Hello PHP

Fig 10

Now we will execute the PHP file. In order to execute the PHP file, we also need to configure the PHP environment in Eclipse. Click on Window -> Preferences -> PHP -> Installed PHPs. It will show the installed PHPs as shown in Fig 11.

Installed PHPs

Fig 11

We can see that none of the installed PHP is configured for the fresh install of Eclipse IDE. Click on the Add Button to configure PHP. It will show the dialog to add executable PHP as shown in Fig 12.

Add PHP Executable

Fig 12

Configure the PHP executable as shown in Fig 12. I have used the default PHP installed on the system. You can also use a different PHP version if it's required for the project.

Installed PHPs with PHP 7.2

Fig 13

The Installed PHPs options will be updated and show the PHP executable added by us. Now we can execute our PHP file with a valid executable configured by us. Click on the Apply and Close Button to finalized our configurations.

To execute the PHP file, right click on the file -> Run As -> PHP CLI Application. It will execute our PHP file and show the output on the console as shown in Fig 14.

Hello PHP Output

Fig 14

This is how we can install the Eclipse for PHP on Ubuntu, create PHP project and execute the PHP files on the console. The same PHP files can also be accessed via Web Server to show the output on the Browser.

Share this blog:

Profile picture for user bhagwatchouhan
bhagwatchouhan