Saturday, May 3, 2014

PHP Program Development Using Eclipse

-----
PHP Program Development Using Eclipse

STEPS

1) There are two approaches to setup PHP Development Environment in Eclipse:
1a) Using pre-package Eclipse (PDT)
1b) Download other Eclipse packages and install PDT into the package.
1.b.1) Browse (latest Eclipse version) at https://www.eclipse.org/downloads/packages/
1.b.2) Unzip the eclipse package into your computer. Find the eclipse.exe program and run.
1.b.3) Go to menu Help/Install New Software…
1.b.4) In the field “Work with:” select “--All available Sites--“
The list will be populated with the available softwares.
Find the item “PHP Development Tools” and check the item.
Click Next.
You can also type “http://download.eclipse.org/tools/pdt/updates/release” in the “Work with:” field. As a result, the list shows you the item only.
2) Restart Eclipse to configure itself after the update.
3) Check that PDT is available in your eclipse.
3.1) Go to menu  Help/About Eclipse.
Click Installation Details.
You should see the PDT item in the Installed Software tab list.
Click Close.
4) Set PHP Perspective layout.
4.1) Go to menu Window/Open Perspective/Other…
4.2) Select PHP in the Open Perspective list.
Click OK.
Your Eclipse will display the PHP Development Environment Layout.
5) Test by creating a new PHP Project.
5.1) Go to menu New/Other…
5.2) Select PHP Project.
5.3) Type the project name, “phpbasics”.
Keep clicking Next until you get the Perspective options.
5.4) You should see the project folder phpbasics in the PHP Explorer window.
5.5) Right-click the name, select New/PHP File.
5.6) Type the file name helloworld.php
Click Next.
5.7)Select PHP Template.
Select “New simple PHP file”.
Click Finish.
5.8)The PHP file helloworld.php is created in helloworld project folder and the content is displayed in the editing window.
5.9) Edit the file as follows:
<?php
echo "Hello World";
?>
5.10) View using Internal Web Browser.
Right-click the file name, select Open With/Other…
Select Internal Web Browser.
5.11) The Internal Web Browser displays the content as plain text.
To execute the text codes, we need to run a web server and view the content through the localhost URL.
6) Setting up Web Server.
6.1) The simplest web server based on Windows-Apache-MySQL-PHP (WAMP) is UwAmp. Download the package from http://www.uwamp.com/en/?page=download set the location as
C:\uwamp\…
6.2) Run uwamp.exe (that can be found at C:\uwamp\uwamp.exe.
6.3) Click Apache Config button.
6.4) Configure Alias directory.
Under Virtual Server list, click the Apache Main item.
Look at the Alias section.
We are going to add an alias that point to our PHP project folder above.
1. Click the plus button.
2. A New Alias item is added to the list.
3. Double-click the item.
4. Enter details as follows:
Alias Name: /phpbasics/
Alias Folder: c:/workspace/phpbasics
(Take note that when you type the folder path, use the separator “/”, refer the screenshot below).
Click OK.
You need to specify the Access Control Setting for the folder as well.
Click OK to return to the main Control Panel.
6.5) Browse localhost (www site)
In the Tools section, click www site.
The UwAmp start page should display a link to your workspace directory under the Alias section.
If you click the link, you should see the PHP file name in the list page.
Click the helloworld.php
6.6) Switch to Eclipse and view using Internal Web Browser.
Right-click helloworld.php and select Run as/PHP Web Application.
In the Run PHP Web Application window, Click OK.
The Internal Web Browser now display the result of PHP script processing.
-----

1 comment:

  1. I like your suggestions they are really helpful. Thank you so much for sharing this post.
    PHP Mysql Developer in India

    ReplyDelete

Labels