I just started to peek into the docs and source (Drupal 6 at the moment) and noticed that there are no classes to be seen, only vast number of prefixed functions. Is this handy? Does such decision have a background? Why?

  • Why are you using Drupal 6? Drupal 8 is on the way!
    – iconoclast
    Nov 6, 2012 at 15:28

2 Answers 2


This is pretty well explained on Drupal programming from an object-oriented perspective.

In short, Drupal has existed for much longer than you could properly use OOP in PHP. Which means, PHP5.

Drupal 7 already uses classes internally in a lot of places and it will probably continue so with Drupal 8.

But this is a step by step process and not everything needs to be a class. For example, it does not make any sense to make modules into a single class.

  • Drupal 8 will be very OOP, pulling in many of the components of Symfony2. But the APIs for developers will still be the backward-compatible hooks, FTMP.
    – paul-m
    Jan 3, 2013 at 21:03
  • It will be a lot more OOP yet, and the point about the API's is not correct. That's just because things aren't completely converted yet. hook_block_*() just got replaced by the plugin system, for example, routing will change, configuration will change, the entity system has changed, ...
    – Berdir
    Jan 5, 2013 at 13:45
  • @Berdir I am very interested in how to leverage OOP PHP in Drupal 7 as I will probably not make the move to Drupal 8 right now. Are there some examples?
    – jerome
    Apr 12, 2014 at 15:02

Drupal was created before oo became better in php5. Objects are being used more in drupal in each release but you need to balance a complete rewrite and adding new features.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.