Hi all,
I'm about to begin work on my first ever PHP project -- building a new website for a small non-profit organization. Coming from a .Net and Java background, object oriented programming comes very naturally for me, but I'm not sure if it's the right approach for bulding a website of moderate complexity in PHP. My understanding is that most PHP-based sites are written mostly in non-OO code.
For a web application I would definitely go the OO-route, but for a fairly simple website, I'm not so sure. The site will consist of about five sections, with one to four content pages per section, containing articles, news, image galleries, and a few forms. There is no complex interaction involved (except for a few fairly simple web forms for writing articles, comments, registering, etc), and no need to maintain state (except for logins). MySQL will be used for data storage.
The code does not really need to be particularly extensible as such -- this is not an enterprise website or a templating engine we're talking about -- but it is important that the code is fairly easy to understand for a programmer with a decent amount of PHP experience. I'm guessing most PHP-programmers are not used to OO-code, so perhaps this is one point in favor of procedural code?
One aspect in favor of OO is that there will be different types of articles that are, in the database level, based on a supertype containing most properties, which of course transaltes very naturally to OO-code.
Perhaps some kind of hybrid approach would be best, using objects for representing the "business objects" etc, but rendering HTML etc using traditional, procedural code?
Comments greatly appreciated. --Rolf