<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.tigerheron.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>IDE</title>
 <link>http://www.tigerheron.com/category/ide</link>
 <description>The taxonomy view with a depth of 0.</description>
 <language>en-US</language>
<item>
 <title>Eclipse and PHP</title>
 <link>http://www.tigerheron.com/article/2008/01/eclipse-and-php</link>
 <description>&lt;p&gt;
  In my last &lt;a
  href=&quot;/article/2007/11/tale-two-patterns&quot;&gt;article&lt;/a&gt;, I talked
  about installing PHP. With PHP installed, you will want to start
  writing code, so today&#039;s article is about developing PHP using the
  open source Eclipse integrated development environment (IDE).
&lt;/p&gt;
&lt;p&gt;
  Eclipse started as a Java IDE and evolved into a generic IDE with a
  strong Java bias. If you start out with a standard Eclipse
  installation and without any Eclipse experience, it may take you a
  while to figure out the best way to set it up for use with PHP. This
  article will make the PHP setup fast and easy.
&lt;/p&gt;
&lt;!--break--&gt;

&lt;h2&gt;Why use Eclipse?&lt;/h2&gt;
&lt;p&gt;
  The reasons for using Eclipse are the same as those for using most IDEs:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Syntax highlighting&lt;/li&gt;
  &lt;li&gt;Syntax validation as you type&lt;/li&gt;
  &lt;li&gt;Editing assistance (indentation, auto-completion, etc.)&lt;/li&gt;
  &lt;li&gt;Access to documentation as you type&lt;/li&gt;
  &lt;li&gt;Refactoring assistance&lt;/li&gt;
  &lt;li&gt;Debugging assistance&lt;/li&gt;
  &lt;li&gt;Integration with other tools (documentation creation, source
      control, etc.)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Currently, the PHP version of a feature is often more limited than
  the Java version. For example, refactoring is limited to moving
  files; if you want to rename a class, method or function, you will
  need to use the Find/Replace tool (which, luckily, can be applied to
  all files in a project). I expect that the PHP tools will improve
  with time.
&lt;/p&gt;

&lt;h2&gt;PDT&lt;/h2&gt;
&lt;p&gt;
  Eclipse consists of a core set of functions and a flexible plugin
  system. The plugins provide many of the features that we usually
  think of as standard parts of an IDE. This is what makes it possible
  to adapt Eclipse to many computer languages.
&lt;/p&gt;
&lt;p&gt;
  &lt;a href=&quot;http://www.eclipse.org/pdt/&quot;&gt;PDT&lt;/a&gt; is the PHP Development
  Tools plugin, which is essential for working with PHP inside
  Eclipse. Over time, you may choose to enhance your Eclipse
  installation with other plugins, but for PHP development, you only
  need PDT (and its few dependencies).
&lt;/p&gt;

&lt;h2&gt;Getting started: Download&lt;/h2&gt;
&lt;p&gt;
  Begin by downloading the all-in-one &lt;a
  href=&quot;http://download.eclipse.org/tools/pdt/downloads/&quot;&gt;Eclipse/PDT
  ZIP file&lt;/a&gt;. This contains all you need to start using Eclipse with
  PDT.
&lt;/p&gt;
&lt;p&gt;
  If you don&#039;t have Java Runtime Environment (JRE) 5 (or greater)
  installed, then you&#039;ll also need to download the latest &lt;a
  href=&quot;http://www.java.com/en/download/manual.jsp&quot;&gt;JRE&lt;/a&gt;.
&lt;/p&gt;

&lt;h2&gt;Getting started: Install&lt;/h2&gt;
&lt;p&gt;
  Start by installing the JRE, if you need it.
&lt;/p&gt;
&lt;p&gt;
  The Eclipse all-in-one package comes as a ZIP file. On Windows, you
  can extract the contents to C:&amp;#92;Program Files. This will create a
  folder called &quot;eclipse&quot;. For easy access, copy the eclipse.exe file
  in the folder and paste it as a shortcut on the desktop.
&lt;/p&gt;

&lt;h2&gt;Getting started: Configure&lt;/h2&gt;
&lt;p&gt;
  Start Eclipse by running the eclipse.exe file. This will ask you to
  select a &quot;workspace&quot;, a folder that will store a collection of your
  projects. You can have more than one workspace.
&lt;/p&gt;
&lt;p&gt;
  Eclipse will suggest a location for the workspace. If you&#039;re happy
  with it, click OK. On Windows, I would suggest using
  something like My Documents&amp;#92;Eclipse. If you don&#039;t intend to create
  multiple workspaces, select &quot;Use this as the default and do not ask
  again&quot; before clicking on OK (you can change your mind later).
&lt;/p&gt;
&lt;p&gt;
  Eclipse should appear and display the Welcome screen (you can return
  to the Welcome screen through the Help menu). Now I will introduce
  you to Eclipse&#039;s rather intimidating preferences system: select &lt;span
  class=&quot;navPath&quot;&gt;Window &amp;gt; Preferences&lt;/span&gt;. Under &lt;span
  class=&quot;navPath&quot;&gt;PHP &amp;gt; PHP Interpreter&lt;/span&gt;, select PHP 4 or 5.
&lt;/p&gt;
&lt;p&gt;
  There are many other options you will want to customize, but this is
  sufficient to get started. You&#039;ll return to this menu many times to
  tweak how Eclipse works.
&lt;/p&gt;

&lt;h2&gt;Getting started: Update&lt;/h2&gt;
&lt;p&gt;
  You should also become familiar with Eclipse&#039;s update system. Select
  &lt;span class=&quot;navPath&quot;&gt;Help &amp;gt; Software Updates &amp;gt; Find and
  Install &amp;gt; Search for updates of the currently installed features
  &amp;gt; Finish&lt;/span&gt;. Select a mirror or let Eclipse select one for you.
  Eclipse will now begin a rather slow search for updates. You can
  place the update dialog into the background and continue to work
  while the search takes place.
&lt;/p&gt;
&lt;p&gt;
  When Eclipse locates all the updates, a window will appear, showing
  you your update options. Select everything and begin the update.
  Once you have installed all updates, you may need to restart
  Eclipse. Your installation is now up-to-date.
&lt;/p&gt;
&lt;p&gt;
  The update method is also the way you add new features to Eclipse.
  Use &lt;span class=&quot;navPath&quot;&gt;Help &amp;gt; Software Updates &amp;gt; Find and
  Install&lt;/span&gt;, but this time select &quot;Search for new features to
  install&quot;. You&#039;ll be able to search for features on a collection of
  sites.
&lt;/p&gt;
&lt;p&gt;
  For example, let&#039;s say you use doxygen to generate your PHP
  documentation. You would click on &quot;New Remote Site&quot;, enter &quot;Eclox&quot; for
  the name and http://download.gna.org/eclox/update/ for the URL. This
  creates a new entry in the sites list.
&lt;/p&gt;
&lt;p&gt;
  You can visit &lt;a href=&quot;http://www.eclipseplugincentral.com/&quot;&gt;Eclipse
  Plugin Central&lt;/a&gt; to find additional plugins to install. But let&#039;s
  leave that for later.
&lt;/p&gt;

&lt;h2&gt;Creating a project for existing PHP code&lt;/h2&gt;
&lt;p&gt;
  Your Eclipse installation may coincide with the creation of a new
  PHP project, but it is more likely that you already have existing
  code you want to use within Eclipse. This is where most people get a
  little stuck&amp;mdash;if you know the magic incantation, the process is
  easy.
&lt;/p&gt;
&lt;p&gt;
  Let&#039;s say you have a PHP Web site at My Documents&amp;#92;Sample&amp;#92;Web Site and
  that you test the Web site using the local server address
  http://localhost/sample.
&lt;/p&gt;
&lt;p&gt;
  Fire up Eclipse and select &lt;span class=&quot;navPath&quot;&gt;File &amp;gt; New &amp;gt;
  PHP Project&lt;/span&gt;. Enter a project name. Disable the &lt;span
  class=&quot;navPath&quot;&gt;Project contents &amp;gt; Use default&lt;/span&gt; toggle and
  browse to the My Documents&amp;#92;Sample&amp;#92;Web Site folder. Click &lt;span
  class=&quot;navPath&quot;&gt;Next&lt;/span&gt;. The files in the My
  Documetns&amp;#92;Sample&amp;#92;Web Site folder are now part of an Eclipse project.
&lt;/p&gt;
&lt;p&gt;
  You probably also reference code through a PHP include path. Select
  &lt;span class=&quot;navPath&quot;&gt;Libraries &amp;gt; Add External Folder&lt;/span&gt; to
  include folders in your Web site&#039;s include path. Click &lt;span
  class=&quot;navPath&quot;&gt;Finish&lt;/span&gt;.
&lt;/p&gt;
&lt;p&gt;
  Our project now appears in Eclipse&#039;s PHP Explorer pane. Eclipse will
  place a .project file in the My Documents&amp;#92;Sample&amp;#92;Web Site folder,
  but your content is otherwise undisturbed. You are ready to use
  Eclipse. You can also continue to work on your code using your
  existing development tools.
&lt;/p&gt;

&lt;h2&gt;Editing with Eclipse&lt;/h2&gt;
&lt;p&gt;
  Using the PHP Explorer pane, you can double-click on a file and have
  it appear in Eclipse&#039;s editor pane. The features here are pretty
  standard, so I won&#039;t talk about them too much. You may want to
  return to the preferences dialog to customize the editing features.
&lt;/p&gt;
&lt;p&gt;
  One nice editor feature is called &quot;code assist&quot;. Eclipse will pop up
  various displays that offer documentation or auto-completion help.
  If the code assist popup doesn&#039;t appear automatically, you can call
  it with Ctrl + Space. One caveat: if you have enabled the Emacs key
  bindings, the magic sequence is Alt + /.
&lt;/p&gt;

&lt;h2&gt;Executing PHP&lt;/h2&gt;
&lt;p&gt;
  You can still run your Web pages by typing
  http://localhost/sample/some_page.php into your Web browser. But
  let&#039;s try running the page from eclipse.
&lt;/p&gt;
&lt;p&gt;
  First, some setup: Using &lt;span class=&quot;navPath&quot;&gt;Window &amp;gt;
  Preferences &amp;gt; PHP &amp;gt; PHP servers&lt;/span&gt;, we create a new
  server, Sample, with a URL of http://localhost/sample. If you would
  like to use your default browser, go to &lt;span
  class=&quot;navPath&quot;&gt;General &amp;gt; Web Browser&lt;/span&gt;, select &lt;span
  class=&quot;navPath&quot;&gt;Use external browser&lt;/span&gt; and enable &lt;span
  class=&quot;navPath&quot;&gt;Default system Web browser&lt;/span&gt;.
&lt;/p&gt;
&lt;p&gt;
  Open up your Web page in the editor. Select &lt;span
  class=&quot;navPath&quot;&gt;Run &amp;gt; Run As &amp;gt; PHP Web Page&lt;/span&gt;. In the
  dialog that appears, verify that the &lt;span class=&quot;navPath&quot;&gt;Launch
  URL&lt;/span&gt; is correct. The page will appear in your Web browser.
&lt;/p&gt;
&lt;p&gt;
  You may notice that the URL has many parameters attached to it.
  These are for coordinating with the debugger. This may be a bug in
  Eclipse since debug parameters should only be added when debugging a
  script.
&lt;/p&gt;
&lt;p&gt;
  Go to &lt;span class=&quot;navPath&quot;&gt;Run &amp;gt; Open Run Dialog&lt;/span&gt;. You&#039;ll
  see that you can create a &quot;run configuration&quot; that controls what
  happens when you select &lt;span class=&quot;navPath&quot;&gt;Run&lt;/span&gt;. For my
  &quot;sample&quot; project, I right-clicked on &lt;span class=&quot;navPath&quot;&gt;PHP Web
  Page&lt;/span&gt; and selected &lt;span class=&quot;navPath&quot;&gt;New&lt;/span&gt;. I set the
  debugger to XDebug, the PHP Server to Sample and the file to
  /Sample/index.php. On the &lt;span class=&quot;navPath&quot;&gt;Common&lt;/span&gt; tab, I
  toggled Run under &lt;span class=&quot;navPath&quot;&gt;Display in favorites
  menu&lt;/span&gt;.
&lt;/p&gt;
&lt;p&gt;
  Now I can run the index.php page by selecting the Run icon on the tool
  bar and then selecting the run configuration I created from the tool
  bar drop down. Using this method, the page appears without the
  debugging parameters attached.
&lt;/p&gt;
&lt;p&gt;
  As far as I can tell, you would have to create one run configuration
  per page. Or, as I pointed out earlier, you could just enter the
  page address directly in your browser and bypass Eclipse.
&lt;/p&gt;

&lt;h2&gt;Debugging PHP&lt;/h2&gt;
&lt;p&gt;
  If you have your system set up to use either the Zend debugger or
  XDebug, it&#039;s easy to debug with Eclipse.
&lt;/p&gt;
&lt;p&gt;
  Configuring PHP for debugging is beyond the scope of this article.
  The Eclipse portion of the setup involves using &lt;span
  class=&quot;navPath&quot;&gt;Run &amp;gt; Open Debug Dialog&lt;/span&gt; to get to a dialog
  very similar to the Run Dialog. Create a configuration for debugging
  index.php and enabled the Debug toggle on the Common tab.
&lt;/p&gt;
&lt;p&gt;
  On the tool bar, you can use the debug button drop-down to select your
  debug configuration. Normally, the debugger will break on the first
  line.
&lt;/p&gt;
&lt;p&gt;
  When you start debugging, Eclipse will offer to switch to the PHP
  Debug perspective, which will give you the right panes and controls
  to run the debugger.
&lt;/p&gt;

&lt;h2&gt;Additional resources&lt;/h2&gt;
&lt;p&gt;
  I hope these instructions give you a head start at using Eclipse for
  PHP. Here are some other places you may get assistance.
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Visit &lt;a
  href=&quot;http://www.eclipse.org/&quot;&gt;http://www.eclipse.org/&lt;/a&gt;, the home
  page of the Eclipse project.&lt;/li&gt;
  &lt;li&gt;Visit &lt;a
  href=&quot;http://wiki.eclipse.org/PDT/&quot;&gt;http://wiki.eclipse.org/PDT&lt;/a&gt;, the home
  page for PDT.&lt;/li&gt;
  &lt;li&gt;Visit &lt;a
  href=&quot;http://wiki.eclipse.org/PDT/FAQ&quot;&gt;http://wiki.eclipse.org/PDT/FAQ&lt;/a&gt; for a list of frequently asked questions about PDT.&lt;/li&gt;
  &lt;li&gt;Use &lt;span class=&quot;navPath&quot;&gt;Help &amp;gt; Help Contents&lt;/span&gt; and
  open up the &lt;span class=&quot;navPath&quot;&gt;PDT User Guide&lt;/span&gt; for the
  online manual.&lt;/li&gt;
&lt;/ul&gt;
</description>
 <comments>http://www.tigerheron.com/article/2008/01/eclipse-and-php#comments</comments>
 <category domain="http://www.tigerheron.com/category/eclipse">Eclipse</category>
 <category domain="http://www.tigerheron.com/category/ide">IDE</category>
 <category domain="http://www.tigerheron.com/category/php">PHP</category>
 <category domain="http://www.tigerheron.com/category/software-developers">software developers</category>
 <category domain="http://www.tigerheron.com/category/xdebug">XDebug</category>
 <pubDate>Wed, 09 Jan 2008 16:29:44 +0000</pubDate>
 <dc:creator>developer</dc:creator>
 <guid isPermaLink="false">92 at http://www.tigerheron.com</guid>
</item>
</channel>
</rss>
