4.3 KiB
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.
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.
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 () and click OK. In the new terminal, change to the project directory and run the following command:
php -S localhost:8080 -t . index.php
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.
via: https://fedoramagazine.org/php-development-on-fedora-with-eclipse/
作者:Mehdi Haghgoo 选题:lujun9972 译者:译者ID 校对:校对者ID