Posted in Technicalon Mar 16, 2005
I just have a short suggestion for PEAR, the PHP Extension and Application Repository. PHP version 5 includes the capability to have interfaces, which are like a definition or description for classes which implement the interface. PEAR should provide a bunch of interfaces for various things, such as database interfaces, authentication schemes, user managment systems, etc.
Then many people can implement the interfaces for many different things. When one implements an interface, they create a class that fulfils all the definitions defined in the interface. This way, developers can implement interfaces when they program classes for things. That way, people can exchange and interchange classes which impliment the same interface.
Let me give an example. There are many ways of implementing authentication for an application. Some will use ldap, others will look users up in a database, while others may use another kind of service from a server. Each authentication method can be written as an class with object oriented programming methods. Now lets say there is an interface that says there needs to be a method called login($username, $password). If each of the different authentication classes contain a method called login($username, $password), then it doesn’t matter to the rest of the application what class is used, because they all contain the required login method.
If PEAR writes and provides interfaces, developers can write their classes to implement the interfaces, then application developers can choose or re-choose from a variety of implementing classes without having to change their underlying code. This would be an incredible advantage in PHP development.