Integrating Symfony into Eclipse PDT

This tutorial is intended to integrate symfony into PHP Delevopment Tool (PDT) as an IDE, so the Code Completion feature can be invoked. Also, we can call the symfony command directly from PDT. This tutorial using Windows XP Operating System, for other OS may have a slight different.

Preparation:

  1. Download the Java Runtime Environment (JRE), the minimum version supported is version 5 of JRE (http://java.sun.com).
  2. Download the Eclipse PDT located at http://eclipse.org/pdt. Eclipse PDT package for windows usually packaged as ZIP archieve.
  3. Download the YAML Editor plugin for Eclipse (http://code.google.com/p/yamleditor/).
  4. If you're using Subversion, also download Subclipse (http://subclipse.tigris.org).
  5. Download the symfony library either by PEAR package or from Subversion repository.

Steps:

  1. PHP must has already been installed, the symfony CLI need the PHP CLI for its to run. And, the path of PHP CLI has already included into PATH system variable. To do this, right click at the My Computer icon, then select Properties. At the System Properties dialog, activate the Advanced tab, then locate the PATH variable from the System variables list. Ensure if PHP CLI path has already included by choosing the Edit button and add the path (for instance, C:\PHP), separated by semi-colon (;).
  2. Install the Java Runtime Environment.
  3. Extract the PDT package, PDT package come with full path already, so just extract it to C:\. The executable file for PDT loacted at C:\eclipse\eclipse.exe and create a shortcut in desktop for easy the use of PDT.
  4. Install all plugins. For installing just extract the plugins into C:\eclipse\plugins. If you are using PDT 2.0, consider using new plugins path C:\eclipse\dropins\eclipse\plugins.
  5. Prepare the folder for all our project files, C:\Project would be a good starting point.
  6. Extract the symfony package (for PEAR package) or copy (Subversion repository) to C:\Project\symfony.
  7. Now, we can run the PDT and integrate symfony in it. Run the PDT by the shortcut we have just created in step 3. First time, Eclipse PDT will asking the location of workspace to be used, just provide C:\Project as the workspace location, also mark Use this as the default and do not ask again if everytime the Eclipse PDT run, this dialog would not be displayed again.
  8. PDT shows Welcome, choose Workbench to start using the PDT IDE.
  9. By default, the active perspective is Resource, so, change it into PHP. Click the Open Perspective button (1) dan activate PHP (2).
  10. Now, make the symfony library as a PHP project. Symfony library has been already prepared in step 6. Choose File > New > PHP Project. Named it as symfony (1) and then click the Finish button (2).
  11. Create our working project, for instance myproject. Do the previous step, name the project as myproject, click Next > (not the Finish button). At the PHP Include Path configuration, activate Projects tab (1) and click the Add... button (2). At the Required Project Selection dialog, mark the symfony project and choose OK. Finish the project creation by clicking the Finish button. This project is still empty by default.
  12. To integrate symfony CLI into PDT IDE, Choose Run > External Tools > Open External Tools Dialog.... To create a new command, right click at the Program tree and choose New. At the Create, manage, and run configurations, provide this parameters:
    • Name: symfony command (showed as command name).
    • Location: ${workspace_loc:/symfony/data/bin/symfony.bat} (use the Browse workspace... button to choose those location).
    • Working Directory: ${project_loc} (for multiple projects, as alternate for single project can be ${workspace_loc:/myproject}, myproject is a project name).
    • Arguments: ${string_prompt} (will prompt string input dialog, use the Variables button to see the others arguments variables).

  13. Create the others command we're generally used, for instance cc. Repeat the previous step and provide the same parameters, except, Name fill with symfony clear cache and Arguments fill with cache:clear (symfony 1.1 up) or clear-cache (symfony 1.0). Repeat for all your favorites commands.
  14. To speed up the command access, add those commands into favorites. Choose Run > External Tools > Organize Favorites.... At the Organize External Tools dialog, use the Add... button to add to favorites list. Mark the check to all commands which are favorites. Those commands now will be available through the toolbar (see figure).
  15. Check if the command has been working correctly. Try to run the command by accesing the toolbar. But, make sure you have select a project first (click at myproject first). At the Variable input dialog leave it blank and choose OK. The command output can be viewed within Console window.
  16. The previous project we have just created first is empty by default (step 11), so, use the symfony command to make it as symfony project. Run the symfony command and provide generate:project myproject (init-poject myproject for symfony 1.0) and examine the result in the Console window.
  17. The last step, is to make PDT compliant with symfony. Activate the Preferences dialog by accessing Window > Preferences.... The settings which must be changed are:
    • General > Workspace > Text file encoding > Other: utf-8.
    • PHP > Editor > Code Folding > Enable folding: off.
    • PHP > Formatter > Formatting > Tab policy: Spaces.
    • PHP > Formatter > Formatting > Indentation size: 2.
  18. You're ready using PDT for your project.

9 Comments

  1. Pingback:Optimizing Eclipse PDT Performance « Toha’s Blog

  2. Thank you very much for this resource. I’m now up and running smoothly on Windows Vista Home Premium.

  3. If you want to follow this tutorial with a Mac :
    – be careful to have php5 installed by default => replace step 1
    – put folder eclipse into your /Applications folder
    – step 12, replace “symfony.bat” by “symfony” only (it’s the unix executable in place of symfony.bat used for windows)
    – step 17, you’ll find “Formatting” preferences there : PHP > Code Style > Formatter

    Everything works good for me, thanks very much.

  4. Pingback:A Newbie Guide for Symfony « Toha’s Blog

  5. Joemon

    Thanks a lot for such a great information. I was searching this whole over internet , but was not getting proper information.

    So once again thanks a lot.

  6. Pingback:Ecplise vs. symfony « Adventures With Technology

  7. I suggest to look at free PHP IDE Codelobster PHP Edition. It has special plug-in for Symfony installation, tasks executing, auto-completion and etc.

  8. Thank you Very Much. No words from my side to appreciate your effort to make lot of people lives easier. I almost spent 3 full days to get right information about symfony installation and integrating in to PDT. If i could have got this before i wouldn’t spend much time on installing PEAR which will install symfony from command prompt.

  9. Had to work with Symfony 1.4 and no one supports it anymore as it’s grown quite old now. Your post saved the day and made it much easier for me. Thanks so much!!

Leave a Reply