May 7 2009

Whenever I tried to get CollabNet for Eclipse plugin working in Eclipse PDT, it always failed, yielding the error “Unable to load SVN client” upon any SVN activity. I did endless amounts of Googling to try to solve the problem, but always came to a brick wall.

The big problem here is that Eclipse is just too new for Ubuntu – even Jaunty. An apt-get install subversion on Jaunty Jackalope will install subversion 1.5.4, which just doesn’t work, and thats where the big problem lies. CollabNet for Eclipse categorically requires Subversion 1.6. Unfortunately the only solution I’ve come up with is to compile subversion and it’s javahl bindings yourself. I’ll try and remember all the steps I took to make it work.

First, download the latest subversion and subversion-deps tgz from http://subversion.tigris.org/. At time of writing they are here and here. Extract them both:

$ tar zxvf subversion-1.6.1.tar.gz
$ tar zxvf subversion-deps-1.6.1.tar.gz
$ cd subversion-1.6.1

You’ll need to install a couple of extra packages (this assumes you’re using Sun’s JRE), and assuming you already had subversion and libsvn-javahl already installed, uninstall a couple:

$ sudo apt-get install libssl-dev sun-java6-jdk g++
$ sudo apt-get remove subversion libsvn-javahl

Configure, make and install subversion. You can check it’s the right version too:

$ ./configure --disable-nls --enable-javahl --with-jdk=/usr/lib/jvm/java-6-sun-1.6.0.13
$ make
$ sudo make install
$ svn --version

Once that’s done, you’ll want to compile the javahl binding. Once installed, check it’s installed correctly too. It’s fairly likely the .so file will be in /usr/local/lib.

$ make javahl
$ sudo make install-javahl
$ sudo updatedb
$ locate libsvnjavahl-1.so
$ sudo ldconfig

Open your eclipse.ini, and after the -vmargs line, add:

-Djava.library.path=/usr/local/lib

replacing the path with the path where the libsvnjavahl-1.so with your correct path.

Now fire up Eclipse, go to Window > Preferences > Team > SVN. The SVN Interface should now say JavaHL (JNI) 1.6.1 and a revision, depending on the particular version of SVN you installed.

I think that’s all the steps I took, so I apologise if I missed something out – if I remember something I’ll add it in!

Update: Compiling javahl requires g++, so I added that into the apt-get install line.

Update 2: Missed out ldconfig after libraries creation.

Update 3: If you still have issues getting it to work, I recommend looking at http://subclipse.tigris.org/wiki/JavaHL, reading it carefully, especially the Troubleshooting on Linux section. The javahltests.jar JUnit tests that are provided on the page may be very handy when debugging problems!

Apr 7 2009

UPDATE!!

For the new Zend Framework 1.8.x series, please refer to this article. This is still here for historical purposes.

This is a pretty simple howto, but here it is anyway!

I assume already that you’ve got a LAMP stack working, and if you don’t, it’s easy as pie to install one in Ubuntu:

sudo tasksel install lamp-server

So now you’ve got your LAMP stack up and running, lets download the latest SVN tag of Zend Framework. At the time of writing, the latest stable is 1.7.8, which I’ll use here. If you want to check for the latest version, visit http://framework.zend.com/svn/framework/standard/tags/ in your browser, and the last folder is the one you want. If you want stable full releases, ignore the RC/PR versions. So, once you’ve determined the version you want, we’ll check out the release:

cd /usr/share/php5
sudo mkdir ZendFramework
sudo svn co http://framework.zend.com/svn/framework/standard/tags/release-1.7.8/

It is likely you’ll need to use sudo for these commands as /usr/share/php5 is owned by root by default. You’ll see a big long list of files being checked out, and once that’s done you’ll have a new folder appropriately named “release-1.7.8″. Create a soft link called “current” to the release folder so you can change the default included Zend Framework version without restarting Apache in the future:

sudo ln -s release-1.7.8 current

You can stop there if you like, and manually add the include path into your PHP scripts using set_include_path. However, if you would like the current Zend Framework included automatically, then continue by opening /etc/php5/apache2/php.ini in your favourite editor. Add the path to your include_path list. For example, if your current include_path is (and this is the default):

include_path = ".:/usr/share/php5:/usr/share/pear"

Then change it to:

include_path = ".:/usr/share/php5:/usr/share/pear:/usr/share/php5/ZendFramework/current/library"

All you need to do now is restart Apache:

/etc/init.d/apache2 restart

In the future, if you wish to change to a new default Zend Framework version (for example 1.8.0), then just check out the SVN directory and change the soft link. You won’t even have to restart Apache, and the changes will take effect immediately! For example:

sudo svn co http://framework.zend.com/svn/framework/standard/tags/release-1.8.0/
sudo rm current
sudo ln -s release-1.8.0 current

If you want to keep up to date with the latest Zend software, then just subscribe to their RSS feed!

Dec 1 2008

I’m really growing to love Eclipse (specifically PHP Development Tools, the PHP extension for it), and how versatile and useful a work environment it is. It really does have everything, and it really helps you get on with what you need to do, when you’re not blogging that is… Now I know why developers have been raving about Eclipse all this time.

One thing I learned today is the huge importance of Perspectives and Views in Eclipse. When Kelvin first said “right, stop using PhpEd, and use this Eclipse thing”, I was overwhelmed by the feature-richness, and my knee-jerk reaction was to just set it up as close to the way I used PhpEd. Thats the first mistake I made, because although I got it close, I missed out on all the glorious features I could’ve been using.

Our Eclipse configuration at work uses Eclipse, PDT, Mylyn, SVN and CollabNet – which integrates wonderfully into our Sourceforge 5.0 server. Mylyn and CollabNet allow task management and allows me to work on Sourceforge artefacts within the Eclipse environment. A rather cool feature is contexts, which allow me to basically attach a list of files to the SF artefact, and when I activate the task in my Task List (note, not “Tasks”, “Task Lists”, a part of Mylyn), it opens all the files I was working on.

Because of our heavy reliance on SourceForge (everything we do has an associated artefact), it makes sense to make use of the CollabNet perspective. If I want to go into “task management mode”, i.e. line up a load of work that has been assigned to me, I switch to the CollabNet perspective. I open an artefact from my assigned artefacts list in the CollabNet view, and it automatically adds it to my Mylyn Task list. I can then say “right, I’m working on this one”, and click a little blob which turns blue, and then I’m working on it. If I’ve been previously working on it, and I attached the context, it automatically opens the files I was working on.

This was meant to be a short homage to Eclipse, but has turned into a little rant, but now that Kelvin set up the SVN repository on Friday properly, we’re actually FINALLY using source control, after the months of me (and Chris) nagging him to get it set up. It’s a little step, but we’re working on the same checkout at the moment, but eventually all that will change. I’ll start bugging him for that soon…

Anyway, if you’re a PHP developer, on a Mac, Windows or Linux, and you’re not using Eclipse PDT yet, I strongly suggest you do so. It’ll make your productivity increase hugely – it did mine!

Nov 27 2008

I had a handy mechanism working on my old old CVS server, and I’ve been using it for some time on my current SVN server.

Basically, whenever you commit a file to the repository, if you have a checked out workspace on the same server, then it will automatically update to the latest revision of the checked out branch or trunk. It’s handy so you don’t have to “svn up” every time you make a change, especially if you’re making lots of tiny changes.

This guide was original from Marc Grabanski’s blog, so 99% of credit goes to him.

cd /svnroot/hooks/
cp post-commit.tmpl post-commit
chmod +x post-commit

You can make a little program to update all your SVN repositories, so nano svnupdate.c:

#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
 
int main(void)
{
  execl(
    "/usr/bin/svn",
    "svn",
    "update",
    "/path/to/mywebsite1.co.uk/www/",
    "/path/to/mywebsite2.co.uk/www/",
    "/path/to/mywebsite3.co.uk/www/",
    (const char *) NULL);
  return(EXIT_FAILURE);
}

You can add as many paths as you like there, just copy and paste the line and edit the path to your needs. You need to then compile it, test it.

gcc -o svnupdate svnupdate.c
env - ./svnupdate

Nano your post-commit file and add in the FULL path to your svnupdate program:

/path/to/svnroot/hooks/svnupdate

Oct 21 2008

I’ve managed to set up a Subversion repository on my 1and1.co.uk hosting now, and even got it working directly from eclipse. This may or may not work on other shared hosts. It was pretty simple, and here’s how I did it:

  • Use PuTTY to connect to your server
  • If you haven’t already got Subversion (type “svn” to check), follow this guide to install it.
  • Set up an SVN repository:
svnadmin create [repository name]
  • Import your existing files:
svn import name-of-folder file:///path/to/repos -m 'First Import'

That’s the repository set up, now to set up Eclipse PDT.

  • You need an SSH client for this – I use TortoisePlink which is built into TortoiseSVN. You can either go down the private key route and have password-less SSH logon, or alternatively the simpler (and much less secure) way is to include the -pw option on TortoisePlink. If you are not concerned about security, then do this. If not, there are plenty of guides on setting up a password-less SSH logon.
  • Open the Subversion config (on Vista, that is C:\Users\[username]\AppData\Roaming\Subversion\config) and in the [tunnels] section, add this line:
ssh = C:/Program Files/TortoiseSVN/bin/TortoisePlink.exe -pw [your-password]
  • Once you’ve done that, right click the PHP Explorer, select Import. In the SVN folder, select “Checkout Projects from SVN”.
  • The URL to your SVN repository should be:
svn+ssh://[1and1-username]@[hostname]/[full-path-to-repository]
  • You can find the full path by typing navigating to the repository directory in PuTTY, and typing “pwd” if you don’t already know.
  • For 1and1, I just use the default website (sNNNNNN.websitehome.co.uk) rather than any of my domains, but I expect it would work with any of the domains you have set up with the destination as your home directory.
  • Clicking next should load up the list of folders in the repository and you can select one, or the entire repository to checkout.
  • Change any options you want changed, and then Finish to import it. You should now see a new (or existing project if you already had one) project in your PHP Explorer, ready for you to use with Subversion enabled.

This list is the steps that I took to do this, and I sourced my information from these various places. This should hopefully help anyone get through the problems of setting up a repository on 1and1 who uses Eclipse PDT.