Exceptions and abstraction

Saturday, August 14th, 2010

So you already know how to handle your errors properly. Even if you're already using exceptions, there are some nuances to the use of exceptions that are important to know and understand in order to write code that is easier to reuse and more decoupled. Let's talk about exceptions and how ...

The “do X or die()” pattern must die

Wednesday, July 28th, 2010

What's the most common pattern for error handling you see in beginner's PHP code? - That's right, do_X() or die('do_X failed);. That's nice and all, as at least you have some sort of error handling, but I think this way of handling errors must go. There is no place for ...

What makes an abstraction good, and why should I care?

Friday, August 28th, 2009

You probably know what abstraction means - making a complex process simpler - but do you know what makes an abstraction good, and why it's important? If you are writing code for a project that lives a bit longer, or has multiple developers working on it, having a good abstraction matters. ...

Dealing with different password validation schemes in a single app

Wednesday, May 20th, 2009

If your application is well thought out, you would not want to save any data that isn't valid. So what do you do, when you need different validation schemes, say for passwords, depending on some special case? For example: Your user passwords need to be at least 8 characters long and ...

Practical uses for reflection

Monday, February 16th, 2009

You may have heard about the reflection feature in PHP. Simply put, it's a way to get a list of methods in a class, a methods parameters, or other "internal" things like that. But how is this actually useful for any common task in application development?

ModelForm developments

Monday, October 20th, 2008

I've been reworking the ModelForm class for ZF a bit. Earlier this year, I discussed porting it to use Zend_Db_Table with Matthew Weier O'Phinney, for using it with Zend Framework. I initially had done some checking on Zend_Db_Table, and some small code changes to modify the class to use it ...

Sharing authentication over multiple sites / Single sign-on

Thursday, September 25th, 2008

At The Group, we're developing some web applications that needed to use the same user database. The applications were originally being developed with separate login for each, but I decided it would be better to share the login code across them. I investigated some ways to achieve sharing a single login ...

More on extensible authentication/access control

Monday, September 1st, 2008

Two weeks ago, I mentioned an easy way to create easily changeable ways for authenticating users. Continuing on that, I've been implementing ways to control user roles and user access for specific pages and modules in my CMS. Naturally, those features too are designed to be easily modifiable. An ACL factory A ...

Implementing swappable authentication methods

Thursday, August 21st, 2008

I've mentioned a CMS I'm working on in a couple of occaions. Lately, I've been tinkering with the user authentication part of it, and stumbled upon a small obstacle: How to make it easy to change authentication methods? Most of the time you probably would like to use a database to ...