Wednesday, August 25, 2010

Modern Java like development environment for PHP

Recently (in June 2010 to be precise) I attended PHP conference in Amsterdam. I just wanted to refresh my PHP knowledge, look around and get some news what is happening in the community before starting new project with the PHP technology. I did not use PHP for last 6 years so that was necessary to discover new solutions, frameworks and trends which appeared during that time. The most important for me were three things: performance, frameworks and tools used to create code and support agile practices like continuous integration and code review. I focused on these things when choosing tutorials and sessions but also when talking to people I met. This time let me share my thoughts and information I got regarding the PHP tools.

Last two years I had pleasure of working with Java and excellent tools created for that technology. IDE is the first to name. I had occasion to work with IntelliJ IDEA and Eclipse. IDEA looks not very pretty (it uses SWING in oppose to nice SWT in Eclipse) but as most paid applications is more polished in terms of UX. Nevertheless both of them allow to quickly navigate through the code, go back and forth in the history, switch between files, jump to method callers, superclass or places where class instance is created and what is even more important they allow to fully refactor the code. It is easy to change method name, move the method or class to other place, extract method or variable from the part of the code and much more. After two years spent with such tools it became natural to have all these useful features right under your fingers. This is why the first questions I asked people I met at the conference was "What IDE do you use? Does it support decent refactoring?". I heard several answers for the first question: Eclipse with PDT, PhpED, ZendStudio, Komodo, Netbeans, PHPEdit. Unfortunately the answer for second questions was always "no". I checked briefly all of those IDEs and in fact none of them supports "advanced" refactoring like global move or rename which I use quite often after playing two years with Java. StormPHP from JetBrains (the company behind IntelliJ IDEA) was not mentioned by anyone. It is a quite new product and looks very promising but it is still quite new, lacks some features and is not free (but much cheaper than ZendStudio for example).

The other interesting topic was Continuous Integration. It is almost a standard in Java world but the PHP folks I met there had no experience in that subject at all. I got partial answer attending Sebastian Bergmann tutorial Quality Assurance in PHP Projects. Sebastian advertised Hudson as his favorite Continuous Integration server tied with set of his own tools like PHPUnit, copy/paste detector and dead code detector. He mentioned also Atlassian Bamboo and phpUnderControl. Overall it looked much better than in case of IDE but I promised myself to test at home if any of mentioned tools is really usable in PHP environment.

The next thing was Code Review. Again no one from the folks I met was able to point any tool. Unfortunately there was no session which covered that subject at the conference so I did a research at home. The only thing I found was another presentation by Sebastian Bergmann which you can find here. He mentioned Atlassian Crucible and Review Board there but again without details so like for Continuous Integration I decided to dive into the topic deeper and test the tools.

Interesting thing is that most of the people at the conference were excited about the continuous integration and code review ideas but they did not use them at work. It looks like PHP community is getting more and more excited about agile approach to software development and tries to follow best Java practices and adapt Java tools or develop their own equivalents. Funny thing is that I met a guy who started to learn Java because he wanted to work with modern, agile environment and mature tools.

After the conference, at home I started to build my own PHP development environment to check if that is possible to have it at least half as good as for Java. I chose Eclipse and PDT, Bamboo, Crucible and Atlassian Connector for Eclipse as I used most of them for last two years and I was one of the authors of Atlassian Connector for Eclipse.

Setting up the Eclipse and PDT went smooth. I installed also Atlassian Connector for Eclipse with support for Bamboo, JIRA, Crucible and Subversive.

Bamboo appeared to support PHPUnit so having the build system in place was not a challenge as well. I found some minor issues and even reported them to Bamboo development team. The guys solved the problems in two weeks or so and the fixes are included in the latest Bamboo milestone build. I did not try but it should not be a challenge to have something more than just PHPUnit run for builds. I can imagine copy/paste detector, dead code detector and even syntax checking run at the build time. Thanks to the Atlassian Connector for Eclipse it is easy to see the build status right in your Eclipse where you can also see the build log, label build, add comment, rerun build and see the list of failed unit tests in JUnit format. Rerun the test locally unfortunately does not work as Atlassian Connector for Eclipse supports only JUnit and there is even no available plugin to run PHPUnit tests inside Eclipse and grab results.

Crucible is also very mature tool and I had no issues to install it, configure and use with Subversion and PHP source code. Creating and performing reviews is a pleasure with Crucible. I installed also Fisheye which allows to browse and search the SVN repository in an easy way. It supports also CVS, Perforce and bunch of other providers. The last step was to create and perform reviews inside Eclipse using Atlassian Connector for Eclipse. Creating a review from the piece of code or set of files was easy and worked fine. I faced the first serious problem when I tried to perform review. Atlassian Connector was not able to open PHP files from the review inside the Eclipse as they came from the outside of the workspace. It took me some time to debug the problem. As a result I raised few issues for the PDT, org.eclipse.wst.sse and Connector itself. I fixed them on the Connector side so it is now possible to view PHP review files inside the Eclipse, go through the comments, add new comments and replies and more.

Finally I managed to have all that stuff in place. I was not fully satisfied with the IDE but Continuous Integration and Code Review solutions worked fine. Builds still needed more configuration e.g. create deploy build but that was more scripting than Bamboo related job.

I hope some of the PHP folks will find this post useful and try to set their own modern Java like development environment for PHP projects. Good luck!

No comments:

Post a Comment