Suggestion for PEAR

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.

Related posts

  1. Cross post code
  2. PHP 6
  3. Why PHP?
  4. Web Site Accessibility and Usability
  5. Those who don’t want broadband Internet

Comment Form

Status Updates

'>
Converted all my SSL apps to Google App Engine. I didn't want to have to pay for my own SSL certificate any more, and App Engine allows for SSL sites with valid and recognized certificates (on their appspot.com domain) for free.
Mar 18, 2010
  • Jacob BYU won their first round game! I'm not sure what to do, this has never happened to me before. Mar 18, 2010
  • 20T? I don't know if I can take any more Mar 18, 2010
  • Categories