In this post I will explain how to turn Eclipse in a full-featured IDE for Symfony2. The other popular MVC framework (Zend) has Zend Studio as an full-featured IDE. Zend Studio is based on Eclipse and we will show in this post how you can turn a standard Eclipse into a full-featured IDE for Symfony2. First you need to install Eclipse. It can be installed from the standard repositories in Ubuntu 12.04. A simple “sudo apt-get install eclipse” will do. Although everybody says you need Oracle Java to run Eclipse with PDT, I have no problems running it under OpenJDK. If you download the latest Eclipse from the download page, choose the “Classic” distribution.
After installing and starting Eclipse, you should install the MarketPlace. Newer distributions of Eclipse come with MarketPlace installed. You can find “Eclipse MarketPlace” under the “Help” menu. This is a software manager for Eclipse that is fast and easy to use. If you do not have it, install it by going to: “Help” > “Install new software” > “All available sites” > type “marketplace” > “Select All” > “Next” > “Finish”.
Now that MarketPlace is installed we can “shop” for some nice additions to Eclipse to make it a full featured Symfony2 IDE. The following packages should be acquired:
- “EGit” and/or “Subversive” for Git and SVN support
- “AnyEdit Tools” for proper whitespace handling and tab conversions
- “PTI – PHP Tool Integration” for support of
- PHP Copy Paste Detector
- PHP Depend
- “Symfony Plugin” for supports of the Symfony 2.1 composer and twig templates
- “DBViewer” plugin for database setup and queries from within Eclipse
Now you also need to install the CodeSniffer standards:
sudo apt-get install php-codesniffer cd /usr/share/php/PHP/CodeSniffer/Standards sudo git clone git://github.com/opensky/Symfony2-coding-standard.git Symfony2 sudo nano Symfony2/ruleset.xml
Remove the last 3 rules that start with “<rule ref=”Symfony2.Commenting” and end with “</rule>”, because somehow those dont work.
You will also have to configure some of the tools from within Eclipse before they work:
- Subversive: After restart Choose the SVNKit version that matches the output of “svn –version” (e.g. choose SVNKit 1.3.8 for SVN 1.6.18).
- PHP executable: Add a PHP executable for path “/usr/bin/php” choose “CLI” and “XDebug”. NB: if this fails remove the “/tmp/zend_debug/” directory if it exists.
- PHP Tools: All pages need to point to the added PHP executable and the internal PEAR library. You also need to set the Symfony2 code style: Go to “Window” > “Preferences” > “PHP” > “Code Style” > “Formatter (PDT Tools)” and choose as “Active profile”: “Symfony [built-in]”.
- PHP CodeSniffer: You need to set Tab width to “4” and you should add and select the Symfony2 CodeSniffer Standard (path “/usr/share/php/PHP/CodeSniffer/Standards/Symfony2”).
- DBViewer: You need to add the path to the file “/usr/share/java/mysql-connector-java.jar” which can be installed using “sudo apt-get install libmysql-java”
NB: If you run into “The currently displayed page contains invalid values.” when trying to configure the PHP executable, you might want to run “sudo chmod -R 777 /tmp/zend_debug/”.
That’s it, enjoy your full-featured Symfony2 IDE!