Silverstripe Captcha

Starting out on some silverstripe projects there will likely be a few bits and pieces finding their way to the blog. SilverStripe is a product I have always wanted to work with, besides being a great example of open source success in New Zealand I'm attracted to the MVC architecture.

I've had a few teething issues, due to deployment issues and module compatability. I have successfully installed one module so far, recaptcha - which relies on the Spam Protection module. Here are the steps:

Install Spam Protection Module

Download the Spam Protection module*
Place that in the root directory of you silverstripe project - the folder with /assets /mysite etc.
Make sure the folder is named 'spamprotection'
Run /dev/build

Install Recaptcha Module

Download the Recaptcha module*
Place this in the same place as above
It should be named 'recaptcha'
Run ?flush=1 (not sure about this step)
Possibly run /dev/build for good measure :-)

Include Recaptcha Field on your form

Get a free recaptcha API key from http://recaptcha.net/api/getkey
Add the public and private keys to mysite/_config.php

RecaptchaField::$public_api_key = 'somekey';
RecaptchaField::$private_api_key = 'anotherkey';
SpamProtectorManager::set_spam_protector("RecaptchaProtector");

Now it is easy to add recaptcha to your forms just like adding any other form element

new RecaptchaField('MyCaptcha');

Everything should work as a charm.

Useful Links:
Recaptcha Module
Install Recaptcha Module
Create recaptcha key
Spam Protection Module
Install Spam Protection Module

*possibly downloading from svn is safest I have been advised to do this after some issues with other modules