Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am a newbie to OOP, and I learn best by example.

You could say this question is similar to Which Scala open source projects should I study to learn best coding practices - but in PHP.

I have heard-tell that Symfony has the best 'architecture' (I will not pretend I know what that exactly means), as well as Doctrine ORM. Is it worth it to spend many months reading the source code of these projects, trying to deduce the patterns used and learning new tricks?

I have seen equal number of web pages dissing and liking Zend's codebase (will provide links if deemed necessary).

Do you know of any other project that would make any veteran OOP developer shed tears of joy?

Please let me add that practicality and scope of use is not a concern at all here - I just want to do:

  • Pick a project that has a codebase deemed awesome by devs way better and greater than me.
  • Write code that achieves what the project does.
  • Compare results and try to learn what I don't know.

Basically, an academic interest codebase. Any recommendations please?

share|improve this question

closed as not constructive by gnat, Mark Trapp, Yannis Rizos Apr 8 '12 at 0:53

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

4  
I'm not an expert, but I don't think OOP is common or necessarily encouraged in PHP. –  asfallows Apr 5 '12 at 16:47
3  
@asfallows Indeed that was the case - but with the release of PHP 5.3, things are changing and there's a definitive tilt towards using all the spanking new features the language provides for OOP coding. –  aditya menon Apr 5 '12 at 16:48
3  
There's no such thing as a "perfect OOP design." –  Robert Harvey Apr 5 '12 at 17:50
1  
I see you are already a member at Code Review Stack Exchange. Use it extensively, it's the most valuable Stack Exchange when learning, we'd love to see and discuss the code you'll be writing while learning about OOP... –  Yannis Rizos Apr 5 '12 at 19:05
1  
@Arkh Harsh. Let's try refraining from personal attacks. If you disagree with asfallows, take the time to write a well written comment. –  Bryan Dunsmore Apr 6 '12 at 13:48

2 Answers 2

up vote 1 down vote accepted

Symfony 2 is probably the best large project to learn from but is pretty big.

I recently found a neat and small open source PHP project called Phrozn (static site generator). It's code base is relatively small so you can examine it pretty fast.

UPDATE:

Phrozn is modern (uses PHP 5.3+ and relies on it heavily), it's extensible, has strict code coverage. It also re-uses code from other well written projects such as Symfony (YAML), Zend (Autoloader), PEAR and Twig.

OOP, uses namespaces and it's very well documented. I'm not saying it's perfect nor that it can be compared to a project like Symfony but it's worth a shot.

share|improve this answer
1  
Can you give us a few more details on Phrozn's codebase? What makes it ideal for studying, other than it's size? –  Yannis Rizos Apr 6 '12 at 12:32
1  
Thanks for the update. –  Yannis Rizos Apr 6 '12 at 13:30
1  
@YannisRizos :) The code can be found at github, so you can take a quick look. github.com/farazdagi/phrozn –  Christian P Apr 6 '12 at 13:33

Well, personally I would say check out Symfony2. It's pretty much the best end-to-end large project that I've seen yet. That's not to say there aren't bad parts to it, but as a whole, it's pretty good.

Now, Zend is in the middle. If you look at the public API, it's pretty good. There are some WTF parts to it, but for the most part it's ok. If you start digging into it more, you'll find a LOT more WTF code...

As far as what to avoid outright:

  • CodeIgniter - Fubar MVC model
  • Kohana - Lots of statics
  • Cake - PHP 4 object semantics
  • Drupal - Not OOP at all
  • Wordpress - Not OOP at all

As far as the rest, you'll find it's hit and miss. There are good and bad parts to all designs. Take a look at Lithium, it's got some really cool design concepts. But it also has a lot of fubar redirection and hackery to get that to work.

And that's what to take to the bank. There is no perfect design, don't try to find one. Instead, look at a lot of them out there and decide for yourself. Try each, try to break them. Try to understand them just by reading them (which is a good test of sane design)...

Just my personal opinion...

share|improve this answer
2  
+1 for symfony2, but more importantly, the entire community building around it. ZF2 is probably worth mentioning as well, though they seem to keep things more abstract. –  Adrian Schneider Apr 5 '12 at 18:57
1  
+1 for symfony2 also. It has a really solid code base, it uses lots of best-practices from other languages and frameworks, a great community, core developers are helpful, reachable people. Although the development is going on with refactoring things along the way to make them better, the current status is ready for production. Fabien Potencier, the creator of Symfony, has a series of blog posts (fabien.potencier.org) about creating a framework with Symfony components. It should be a good starting point, as he wrote this posts to help people learning stuff. –  Hakan Deryal Apr 5 '12 at 20:54
    
Reading symfony2 source-code is actually an inspiration while not being too complex to grasp, good point. However it's not TDD developed, which probably would be one cornerstone for the "perfect" OOP "design" - because no design is perfect which means you need to change it and for that you need the tests. –  hakre Apr 5 '12 at 21:10
2  
Well, you cannot compare Symfony, Zend or Kohana to Wordpress and Drupal, seriously. –  Daniel Ribeiro Apr 5 '12 at 23:02
    
Thank you! I have downloaded Symfony, I will commence understanding it. Thanks for confirming my fears about CodeIgniter: I once heard on the SilverStripe IRC that "CodeIgniter is a beginner OOP Framework and does a lot of beginner mistakes" - and they started writing in PHP4, but haven't had the time to extensively refactor so I doubt they have used all the great features this language offers. Please note that I am NOT dissing CI! I love the framework and heaven knows how many projects became easier for me because I used it. But for a learning purpose it might not be the best. –  aditya menon Apr 6 '12 at 2:36

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