{"id":109209,"date":"2020-02-14T08:00:00","date_gmt":"2020-02-14T08:00:00","guid":{"rendered":"https:\/\/fedoramagazine.org\/?p=30437"},"modified":"2020-02-14T08:00:00","modified_gmt":"2020-02-14T08:00:00","slug":"php-development-on-fedora-with-eclipse","status":"publish","type":"post","link":"https:\/\/sickgaming.net\/blog\/2020\/02\/14\/php-development-on-fedora-with-eclipse\/","title":{"rendered":"PHP Development on Fedora with Eclipse"},"content":{"rendered":"<p><a href=\"https:\/\/projects.eclipse.org\/projects\/eclipse\">Eclipse<\/a> 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. <\/p>\n<p> <span id=\"more-30437\"><\/span> <\/p>\n<h2>Installation<\/h2>\n<p>The software is available from Fedora&#8217;s official repository. To install it, invoke: <\/p>\n<pre class=\"wp-block-preformatted\">sudo dnf install eclipse<\/pre>\n<p>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: <\/p>\n<pre class=\"wp-block-preformatted\">sudo dnf install eclipse-pdt<\/pre>\n<p>This will install PHP development tools like PHP project wizard, PHP server configurations, composer support, etc. <\/p>\n<h2>Features<\/h2>\n<p>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. <\/p>\n<h2>Sample project<\/h2>\n<p>Now that the IDE is installed, let&#8217;s create a simple PHP project. Go to <em>File \u2192New \u2192 Project<\/em>. From the resulting dialog, select <em>PHP project<\/em>. Enter a name for your project. There are some other options you might want to change, like changing the project&#8217;s default location, enabling JavaScript, and changing PHP version. See the following screenshot. <\/p>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2020\/02\/php-development-on-fedora-with-eclipse.png\" alt=\"\" class=\"wp-image-30438\" \/><figcaption>Create A New PHP Project in Eclipse<\/figcaption><\/figure>\n<p>You can click the <em>Finish<\/em> button to create the project or press <em>Next<\/em> to configure other options like adding include and build paths. You don&#8217;t need to change those in most cases. <\/p>\n<p>Once the project is created, right click on the project folder and select <em>New \u2192 PHP File<\/em> to add a new PHP file to the project. For this tutorial I named it <em>index.php<\/em>, the conventionally-recognized default file in every PHP project. <\/p>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2020\/02\/php-development-on-fedora-with-eclipse-1.png\" alt=\"\" class=\"wp-image-30440\" \/><\/figure>\n<p>Then add the your code to the new file. <\/p>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2020\/02\/php-development-on-fedora-with-eclipse-2.png\" alt=\"\" class=\"wp-image-30441\" \/><figcaption>Demo PHP code<\/figcaption><\/figure>\n<p>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. <\/p>\n<p>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. <\/p>\n<p>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 (<img decoding=\"async\" class=\"wp-image-30444\" style=\"width: 21px\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2020\/02\/php-development-on-fedora-with-eclipse-3.png\" alt=\"Terminal Icon\" \/>) and click <em>OK<\/em>. In the new terminal, change to the project directory and run the following command:<\/p>\n<pre class=\"wp-block-preformatted\">php -S localhost:8080 -t . index.php <\/pre>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2020\/02\/php-development-on-fedora-with-eclipse-4.png\" alt=\"\" class=\"wp-image-30446\" \/><figcaption>Terminal output<\/figcaption><\/figure>\n<p>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.<\/p>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2020\/02\/php-development-on-fedora-with-eclipse-5.png\" alt=\"\" class=\"wp-image-30442\" \/><figcaption>PHP output in Fedora<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s official repository. To install it, invoke: sudo dnf install [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":109210,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48],"tags":[108,884,910,45,61,46,47,911],"class_list":["post-109209","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-fedora-os","tag-development","tag-eclipse","tag-eclipse-for-fedora","tag-fedora","tag-fedora-project-community","tag-magazine","tag-news","tag-php"],"_links":{"self":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/109209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/comments?post=109209"}],"version-history":[{"count":0,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/109209\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media\/109210"}],"wp:attachment":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media?parent=109209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/categories?post=109209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/tags?post=109209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}