web development and photography
Posts tagged web
IWMW2009
May 28th
The Institutional Web Management Workshop (IWMW 2009) will be held at the University of Essex from Tuesday 28th to Thursday 30th July 2009.
This is generally a great chance to catch up with what’s going on in the Higher Education web world. Oh and there’s great food and lots of booze too, not that I’m swayed by such things of course…
IWMW 2008
Jul 21st
Off to Aberdeen today! Hopefully this year’s conference bag will be even better than last year’s…

symfony and LDAP
May 1st
I’ve recently been looking at the essential (ie why isn’t it included in the core?) symfony plugin sfGuard. It offers are really nice, simple way of building a simple user, role, and permissions system into your symfony app.
The great thing is that with a little tweaking (documentation not great) you can add a custom LDAP lookup class, which overrides the standard built in user password lookup. Ok, you need to write your own class, or use a 3rd party one. But the basics of LDAP are built into php5, and it’s really not hard to do.
One problem I had was that sfGuard is designed to make it impossible to do an LDAP lookup and an internal check for a superadmin user. The reasons are a little esoteric, and have to do with mixing static and non-static contexts. Basically, the only option is to change one of the sfGuard library classes. Specifically sfGuardPlugin/lib/model/plugin/PluginsfGuardUser.php
Adding in this fixed things:
if ($callable = sfConfig::get('app_sf_guard_plugin_check_password_callable_both'))
{
$result = false;
$result = $this->checkPasswordByGuard($password);
if (!$result)
{
$result = call_user_func_array($callable, array($this->getUsername(), $password));
}
return $result;
}
which meant I had to use a special ‘check_password_callable_both’ option in the app.yml file. But at least this way it did checkPasswordByGuard() first, and then tried my added in LDAP class second.
Is there another way of doing this? I don’t know. Probably. But this seemed to work for me, and perhaps could be included in the sfGuard plugin by default. I guess I should get in touch with the developers to check…
symfony
Apr 23rd
I’ve recently been deploying some symfony (http://www.symfony-project.org/) applications at The University of Kent. I’m pleased with the results.

Symfony is an MVC framework, along the lines of Ruby on Rails, but based on PHP5. It is widely used, including yahoo bookmarks:
http://www.ysearchblog.com/archives/000376.html
and the beta of the new version of del.icio.us:
http://www.symfony-project.org/blog/2007/10/02/delicious-preview-built-with-symfony
Why?
So why did I choose symfony as a framework for web development at Kent, as opposed to the many others (for example cakePHP and codeIgniter)? There are lots of reasons, as I’ll show later. But the three most important are:
- it’s well documented
- there’s a good and helpful user community
- it’s very powerful
Huh?
Documentation? No, don’t need that. Well clearly that’s what a lot of frameworks seem to think. Although most frameworks – and certainly cake and codeigniter – have great communities, their documentation isn’t always great. For example, cake has a kind of ‘getting started’ document and then sort of leaves the rest up to you. Fine if you want to do basic stuff, but not so great if you want more.
Plugged in
The key thing with a good community, apart from helpful advice on forums, is the availability of plugins. Symfony has loads of those, as you can see here http://trac.symfony-project.com/wiki/SymfonyPlugins. Many are pretty esoteric, but a lot are really useful, such as a really nice user security plugin called sfGuard.
OOPs
As for being powerful, the thing you notice first off with symfony is that it’s only compatible with php5. Only? That seems odd. Brave almost. But surely they could’ve tweaked things a little to get php4 support? Once you take a look under the hood, you realise that symfony is totally object-oriented. Inheritance, mixins, overloading, public/private/protected. It’s all there, beautifully structured. What’s great about the use of OOP and php5 is that symfony uses autoloading, so a lot of classes (including plugins) are easily available without lots of includes all over the place.
Less is more
OK so symfony sounds complicated, and in many ways that’s true. The real power of the framework comes from its flexibility. There are dozens of configuration files which let you change many aspects of how your application works, from how the urls appear to fine details in a pre-generated backend system. This power creates complexity. But really, any good php developer ought to be able to cope with this kind of thing.
But the power of the system also lies in its potential to bypass many parts of symfony altogether. For example, you don’t have to use the built-in database abstraction layers. Just use anything you want instead, including (heaven help us!) raw SQL. You don’t have to use the built-in scriptaculous ajax methods (but why wouldn’t you).
Scriptaculous
Which brings me to another nice feature: ajax. Although not unique to symfony, it is nonetheless made spectacularly easy in symfony to do some really nice things with ajax. And I do mean the real asynchronous ajax stuff, not just the javascript eye-candy that has become known as ajax.
Saving time
One of the main reasons for using a framework is to give your code some structure, rather than the usual ordered chaos of a hacked-together website. That’s all very well, particularly for big projects. But a real plus for many developers is the ability to produce web applications quickly. symfony can help there too.
One feature that really helped me recently was the admin generator. Beautiful. I basically made a mini-phpMyAdmin interface in about 5 mins. Add to that the sfGuard plugin for authentication and authorization, and in about 10 mins you have a fully-featured admin system. And it actually looks good too.
There are also great time-savers for things that sane developers hate. Things like forms and input validation.
Summary
symfony is a great way to save time and develop good, maintainable code. It’s a powerful framework, and is surely set to grow, particularly now that yahoo have adopted it for a couple of applications. It’s not perfect, but offers a huge amount of power and flexibility, and speeds up application development significantly.