PHP Development on Fedora with Eclipse

Eclipse is a full-featured free and open source IDE developed by the Eclipse Foundation. It has been around since 2001. You can write anything from C/C++ and Java to PHP, Python, HTML, JavaScript, Kotlin, and more in this IDE.

Installation

The software is available from Fedora’s official repository. To install it, invoke:

sudo dnf install eclipse

This will install the base IDE and Eclipse platform, which enables you to develop Java applications. In order to add PHP development support to the IDE, run this command:

sudo dnf install eclipse-pdt

This will install PHP development tools like PHP project wizard, PHP server configurations, composer support, etc.

Features

This IDE has many features that make PHP development easier. For example, it has a comprehensive project wizard (where you can configure many options for your new projects). It also has built-in features like composer support, debugging support, a browser,a terminal, and more.

Sample project

Now that the IDE is installed, let’s create a simple PHP project. Go to File β†’New β†’ Project. From the resulting dialog, select PHP project. Enter a name for your project. There are some other options you might want to change, like changing the project’s default location, enabling JavaScript, and changing PHP version. See the following screenshot.

Create A New PHP Project in Eclipse

You can click the Finish button to create the project or press Next to configure other options like adding include and build paths. You don’t need to change those in most cases.

Once the project is created, right click on the project folder and select New β†’ PHP File to add a new PHP file to the project. For this tutorial I named it index.php, the conventionally-recognized default file in every PHP project.

Then add the your code to the new file.

Demo PHP code

In the example above, I used CSS, JavaScript, and PHP tags on the same page mainly to show that the IDE is capable of supporting all of them together.

Once your page is ready, you can see the result output by moving the file to your web server document root or by creating a development PHP server in the project directory.

Thanks to the built-in terminal in Eclipse, we can launch a PHP development server right from within the IDE. Simply click the terminal icon on the toolbar (Terminal Icon) and click OK. In the new terminal, change to the project directory and run the following command:

php -S localhost:8080 -t . index.php 
Terminal output

Now, open a browser and head over to http://localhost:8080. If everything has been done correctly per instructions and your code is error-free, you will see the output of your PHP script in the browser.

PHP output in Fedora
Fedora Project community

16 Comments

  1. Truls Gulbrandsen

    Unfortunately eclipse seems to be broken:
    [root@localhost ~]# dnf install eclipse –skip-broken
    Last metadata expiration check: 0:50:05 ago on fr. 14. feb. 2020 kl. 10.33 +0100.
    Dependencies resolved.

    Problem: package eclipse-jdt-1:4.14-5.fc31.noarch requires eclipse-platform = 1:4.14-5.fc31, but none of the providers can be installed
    – package eclipse-platform-1:4.14-5.fc31.x86_64 requires glassfish-el >= 3.0.1, but none of the providers can be installed
    – cannot install the best candidate for the job
    – package glassfish-el-3.0.1-0.12.b08.module_f31+6519+12cd0b27.noarch is filtered out by modular filtering
    – package glassfish-el-3.0.1-0.12.b08.module_f31+6793+1c93c38e.noarch is filtered out by modular filtering

    – package glassfish-el-3.0.1-0.11.b08.fc31.noarch is filtered out by modular filtering

    Package Architecture Version Repository Size

    Skipping packages with broken dependencies:
    eclipse-jdt noarch 1:4.14-5.fc31 updates 31 M
    eclipse-platform x86_64 1:4.14-5.fc31 updates 40 M

    Transaction Summary

    Skip 2 Packages

    Nothing to do.
    Complete!

    • Alexander Borro

      Download it from the eclipse website and install that way, that usually worked for me. While I do not use it any more eclipse installations have been broken/problematic since forever in Fedora as I recall. I wonder how the author just got it to work.

      Also, it has proven to be a pain in any case braking with Java open SDK updates and third party dependencies. I was often fixing things manually with updates.

      Today I would not recommend this IDE. I switched to vscode on Fedora a long time ago and everything “just works” once you know what you are doing. Pardon the NVidia ray-tracing quote πŸ™‚

      • I have had my problems with Eclipse, mostly in terms of its complexity and very intricate configurations, but I don’t remember seeing its packages broken, at least during the last 4-5 releases I can recall.

    • Jeremie Barnes

      I was able to install by doing “sudo dnf module enable eclipse:latest”

      • Mark LaDoux

        That should have been in the article. This fixed mine, I couldn’t install without enabling the module that the article fails to mention. Seeing as the module isn’t enabled by default, it should have been mentioned.

      • qbl

        Thanks, agree it should be in article

  2. I prefer netbeans πŸ˜‰
    netbeans.apache.org

    • There was a discussion in Fedora mailing lists to include NetBeans in Fedora. I hope that succeeds. I like NetBeans too.

  3. Maciej

    Yes you can do that, but first add another 32GB of RAM to your PC or you can just use VScode…

    • Ben Knobi

      … then let the language server consume the 32G of RAM with a few projects open.

  4. Fedora lover

    No one gonna make development like that in 2020 with PHP
    Why you make pointless articles about software development. But not making articles directly related with the OS.

    • “Fedora lover”:

      Eclipse is used by millions of developers. Also, the Fedora Project is not just about creating an operating system. The Fedora Project’s main goal is actually to “advance free software“.

      • Bill Chatfield

        I think people just like VSCode because it has a black theme. If they actually explored the functionality differences between VSCode and Eclipse, they would not bother with VSCode because it is just a toy compared to Eclipse.

  5. Jetbrains best!

Comments are Closed

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. Fedora Magazine aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. The Fedora logo is a trademark of Red Hat, Inc. Terms and Conditions