1.4. Installing and Using the Eclipse PDT

Installing and setting up the Eclipse PDT requires six steps.

1.4.1. Step 1: Downloading the PDT

Get started by navigating to the PDT download page (http://www.eclipse.org/pdt/downloads/) and scrolling down to the All-In-One downloads section. Select your operating system, then choose a mirror for downloading (generally, the default mirror will be highlighted and will work just fine).

1.4.2. Step 2: Unpacking the PDT Archive

After the file finishes downloading, unzip the file. A folder called "eclipse" should appear in the same directory as the downloaded archive.

Drag this folder into your Programs or Applications folder (or wherever you want to keep it) and open it up. There will be a purple icon that says "Eclipse"; double-clicking the icon launches the IDE and brings up the loading screen (see Figure 1-14).

Figure 1.14. Loading the Eclipse PDT screen

1.4.3. Step 3: Choosing Your Project Workspace

After a moment, a dialog box will pop up (see Figure 1-15) that asks you to select your workspace. You'll be working with XAMPP, so set the path to the XAMPP htdocs folder (see Figure 1-16). You can find this in the xampp folder you installed previously.

Figure 1.15. Selecting your workspace in the Eclipse PDT

Figure 1.16. Selecting the htdocs folder from the XAMPP installation

Selecting this folder and checking the "Use this as the default and do not ask me again" box enables you to tell Eclipse to create new projects in the htdocs folder automatically, which simplifies testing your code.

After clicking "Choose," close the welcome screen that shows up by clicking the "X" in the tab at the top, next to "Welcome" (see Figure 1-17), which takes you to the editor.

Figure 1.17. Clicking the "X" next to "Welcome" closes the welcome screen

1.4.4. Step 4: Creating Your First Project

You're almost to the point where you can code a simple blog. The next step is to create a project. Do this by clicking the New Project icon, which is at the top left of the Eclipse toolbar (see Figure 1-18).

Figure 1.18. Creating a new project in Eclipse

Select "New Project..." from the drop-down menu that pops up. This brings up a new dialog (see Figure 1-19); select "PHP Project" from the list of project types and click "Next."

Figure 1.19. Creating a PHP project

The next dialog presented asks you to name your project and provides some customization options for the project (see Figure 1-20). Name the project "simple_blog" and leave all the settings at their default values.

Figure 1.20. Creating the simple_blog project

Clicking "Finish" will bring you back to the editor; your newly created project will be listed in the left-hand panel. At this point, Eclipse lets you know that this project type is associated with the PHP perspective, and it asks whether you'd like to switch to the PHP perspective. It makes sense to do this because you're working with PHP, so select, "Yes."

1.4.5. Step 5: Creating a File

The final step is to create a file that you can start coding in. At first you'll be doing basic exercises to get a feel for the language, so call your first file test.php.

To create the file, right click the simple_blog project, hover over New, and then click PHP File from the resulting drop-down menu (see Figure 1-21).

Figure 1.21. Creating a PHP file in Eclipse

This brings up a new dialog where you can name your file (see Figure 1-22).

Figure 1.22. Create test.php and click "Finish"

Clicking Finish creates your first file and means you can now start coding.

1.4.6. Step 6: Writing Your First Script

The final step is to make sure that everything is set up correctly and ready for you to start developing your blog. You can do this by writing a short script to ensure that PHP is working in your test.php file. Add this code to the test.php file and save:

<?php
    echo "Hello world!";
?>

Now open any browser and navigate to http://localhost/simple_blog/test.php; what you see should look like Figure 1-23).

Figure 1.23. test.php loaded in a browser, displaying your first script!

If the above text is visible, you have installed XAMPP and Eclipse successfully, and you're ready to start building your blog.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.77.63