Eclipse - installation and configuration + PHPEclipse (tutorial)


Uploaded by zathruswriter on 24.11.2011

Transcript:
Hello everyone! This is Zathrus Writer and you are watching the second episode of our
programming series, featuring Eclipse Software Development Kit.
In this episode, we will look into the installation of Eclipse itself. Also included will be requirements
- like Java - that you need to fulfill in order to run it. In the end, we will look
into installing and configuring PHPEclipse - a plugin for PHP development.
So let's start with the installation. First of all, you may want to check if you have
Java installed on your computer. Because Eclipse is written in Java, it will not run unless
you have it installed. Good news is that the executable file - for Windows at least - will
automatically check if Java is present and will show you a warning if it's not.
In case you don't have Java installed on your PC, simply navigate to www.java.com and download
the latest version. Installation of Java is quite straightforward and consists of a simple
wizard - just like any other installation out there.
Once you have Java installed, all you have to worry about is going to www.eclipse.org,
clicking the Download Eclipse button and choosing to download Eclipse Classic version. Now,
reason for me to download exactly this version is that it always worked from the start. Of
course you can download any version and the outlined procedure would probably work for
you as well if you're feeling adventurous!
Then simply choose your download location - aka a mirror - and off you go... to a coffee
break or whatever, since it will take a while to download 150MB of data.
Once downloaded, open it and extract the eclipse folder anywhere to your computer. If you have
Windows XP system or higher, you will be able to open the ZIP file directly by double-clicking
it. Otherwise you might need to install something like 7-ZIP or some other archiver to extract
this data.
Then navigate into the eclipse folder and voi-lá! Run the eclipse.exe file to see your
very own Eclipse running on your computer!
When you first start the program, you will be asked to select a so-called workspace folder.
This is the folder in which Eclipse will store all your files, so it's best to set it to
your htdocs folder, where your web development work is located. A subfolder by the name of
metadata - starting with a period - will be created in your workspace folder as well.
This is a folder where Eclipse stores its settings, so if you ever want to move to another
PC, simply grab the eclipse folder and this metadata folder and transfer them to a new
place. Yeah, piece of cake.
Upon starting, you will be welcomed by a welcome screen, which you can successfully ignore
and furthermore close, so it does not bug you anymore. At this point, you will only
have a development environment that is meant for developing Java stuff, so there's not
much to look at yet. However, there is lots to look at in the preferences dialog. You
can access it by going to the Window menu and choosing Preferences.
Now, you're absolutely free to explore this area on your own and skip this part of the
video completely if you so desire. What you will see here are some options that made my
life easier while working with Eclipse, so it's more of a tips thingy than anything else.
First one that makes my eye pleased is the Show heap status checkbox. This is really
more of a visual thing and when ticked, it will show you how much memory is Eclipse using.
In the Editors section, I use to expand the list of recently opened files to 10 and since
I like to see line numbers even in ordinary text files - not just PHP or HTML files - I
tick this option in the Text editors section. I also usually opt-out of spell checking,
since I don't want spelling to be checking MySQL dumps or htaccess files, as it tends
to slow Eclipse quite a lot.
Let's move on to the Keys section. This is a part showing all keyboard shortcuts available
in Eclipse itself. And to be honest, some of them really suck or maybe I'm just an old-schooler...
but anyways - who would use CTRL+K for a Find Next command if most of the editors use F3
key here? Ok, so let's improve this, and while at it, let's also update the Find Previous
and Go To Line commands, since these don't make sense to me either.
For Startup and Shutdown, I simply untick this second option, so Eclipse does not bug
me with confirmation every time I try to close it. And I also want the workspace to be refreshed
upon starting Eclipse, so I get the latest code changes analyzed in case I changed something
outside Eclipse. This is quite important especially if you're working with PHP and want your code
completion to work correctly.
I also opt-out from automatic updates, since they failed me a few times before already
and I don't really trust them anymore.
At the Workspace section, I tend to change files encoding to UTF-8, since that's the
character set I use most frequently. If you're Japanese or something, you can choose UTF-16,
however this will make your files a lot bigger, so if you're not using characters contained
in that encoding, I'd advice to switch to UTF-8 and switch back to UTF-16 later in case
you need an exception.
Also, the only correct new line delimiter for me is - and always was - Unix line endings.
Now, we might get into this in some later videos but if you're curious, there is a link
to a nice article about this in the video description.
This really is just about everything I use to change in the default settings, so let's
move on to installing PHPEclipse now.
Start by opening your browser and navigating to www.phpeclipse.com, where you will see
the link we need to copy and paste into Eclipse on the right side. Installation of new features
into Eclipse is mostly quite easy, so all you need to do is hover your mouse over the
Stable Update Site link and copy the link location. Or click on it and copy the location
from your address bar.
Now switch back to Eclipse, click on the Help menu and choose Install New Software.
This is the installer interface for Eclipse, where you can add new plugins and features.
It uses a list of repositories - in other words locations where plugins are stored.
You will see 2 predefined repositories already in the list - these contain list of official
plugins supported by the Eclipse project. But none of them is PHPEclipse, so we need
to add our own repository.
To do this, click on Add button and type any name into the Name text field. This will only
serve the purpose of you being able to recognize the repository, so name it accordingly. Then,
paste the link we have just copied over from the PHPEclipse website into the Location text
field and click OK.
If everything goes as it should, you will see PHPEclipse Stable Builds checkbox that
just appeared in our plugins list. Expand this to see all components available and choose
the ones you will use. I only use PHPEclipse, so I choose that.
When you click the Next button, you will see a list of all components you chose to install.
Click next again to accept licence agreements for each of these and then Finish to start
the installation procedure.
PHPEclipse may take a while to download, since it's not exactly a small package, so be patient
here and if it looks like nothing is happenning, it might actually be your Internet connection
letting you down.
Upon successfull download, you will be asked to confirm that you really want to install
this content, since it is unsigned. Confirm this or view details of all the files that
are about to be installed first and off you go.
Once installed, you will do best to restart Eclipse, so nothing fails when you try to
use the plugin.
OK, so the first thing that is not that obvious is a whole new perspective that was added
into Eclipse. Perspective is basically a visual layout that you currently see - the working
environment in other words. PHPEclipse automatically installs a PHP perspective, which you can
access by clicking on the perspectives button and choosing Other - PHP.
Now, that's more like it. You might have noticed that the left section has changed into a Navigator
and bottom section contains 4 new tabs, that unfortunatelly I find completely useless,
so I basically just close them all :-D
When open, there are 2 buttons on the right side of each tab. As shown on the Outline
tab, first one is minimize - which will move the tab out of the view and minimize it into
a compact icon. You can then restore it using the restore button or you can actually just
open in, which will bring the tab to front, but will minimize it back as soon as some
other element becomes active. These minimized icons can be moved around the perspective
as well, so again - don't be afraid to experiment :-)
Let's have a look at some PHPEclipse options, as we're just about to end this video. So,
as we open Preferences again, we'll see that a new item - PHPEclipse - has been made available
to us. Are you as eager to explore it as I am? Good! Let's get to it than, shall we?
PHPEclipse configuration has quite a few options, so I'll only run through the ones I consider
vital for a user experience.
First of all, you can change colors to suit your needs in the Syntax tab of the PHP option.
The selection is quite vast, however I wasn't really able to transfer colour settings when
I was moving to another computer, so I simply leave this at its default values.
There is quite a lot to explore in the Typing section as well.
Apart from standard word-wrapping, you can choose to wrap quoted strings as well. Now,
the latter, however works a bit differently than I would expect. When you have a quoted
text and you press Enter in that text - wanting to go to a next line - PHPEclipse will automatically
close the quotes for you and open a new set on the next line. This is really useless for
me, so I usually turn it off. You can also have any text pasted into a quoted string
to be escaped, which could be a handy feature, although I don't see why this is conditioned
by having the wrapping turned on. Anyways, it's there for your usage.
The rest of these options are quite self-explanatory, like this automatic quotes, brackets and comments
closing.
Now, I wasn't able to successfully test code folding in this version - might be something
on my part... but feel free to check out my previous crash course video to see code folding
in action.
I always loved this trailing spaces removal option in Editor section. What it does is
that it removes all empty spaces you might have left in your code. For instance when
you press Enter 4 times and start typing on the 4th line, the editor will most probably
leave tabs everywhere on those previous 3 lines. If you are having lots of code like
this, this option comes really handy. It removes all those tabs in empty lines, but nowhere
else! This also removes spaces and tabs from the end of lines where no other code follows
them, saving lots of space. Sweet!
In PHP Parser, you can select which problems you want to be visually notified of. The notification
takes a form or underlining the problematic parts of code, and also marking them next
to the scrollbar on right side, so you can instantly see them. For visual examples, refer
to the previous crash course video or try it on your own!
This is just about everything on installing and configuring Eclipse and PHPEclipse that
is probably sane to present for the moment, so thank you all for watching and I hope this
helped you in some way or another.
In the next video, we'll look into the actual usage of PHPEclipse itself, so you'll see
what all these settings actually do.
Until then, have a great time and adios!