tags:

views:

616

answers:

8

So I've read Drupal, Joomla, Magento, Wordpress all have bad PHP code... which is a shame because I was referring to them to see 'what they did' so I could hopefully get some insight. I assumed popular software meant it would have decent coding.

So, what is the best PHP open source application to study?

+3  A: 

Magento is based on Zend Framework - so I'm surprised that it's considered to have "bad code". Drupal has continual, terrible security holes due to its bad code!

Chris KL
I think because it is abundant with singletons... just my guess.
alex
Building an application on top of a framework does not guarantee good architecture. Not to mention that ZF is somewhere between framework and components repository.
Ionuț G. Stan
+4  A: 

Take a look at the Zend Framework; it's huge, but I've picked up some useful tips just from reading their coding style guide and their reasoning behind it.

Ant P.
A: 

You can also look at the ModX CMS, it's a nice simple clean cms. The api is well documented, and the code seems nice and clean.

gdey
I like MODx, but the code isn't that good. Have you actually read it? There are C style for-loops where you should use a foreach, for example.
stesch
A: 

Joomla is not exactly an example of good php code. Mediawiki, the software used by the wikipedia is pretty much better.

Luixv
I did hear it once had a vulnerability with preg_replace and the e (evaluating) flag in a regex. But I'm sure it's been fixed.
alex
+4  A: 

Don't study just one. Study two or three and compare them. I'm always learning better when I consult multiple materials. That being said I recommend you to look at the major frameworks (in no particular order):

  • Zend Framework
  • Symfony
  • CodeIgniter
  • ezComponents
  • CakePHP
Ionuț G. Stan
A: 

I think the best code example in PHP is WordPress. I studied it when I wasn't already a newbie in PHP, but I think it's even possible to learn this language by reading the code.

Vladimir Kadalashvili
Wordpress, seriously?alex is asking about good practices and patterns.I'm not sure Wordpress qualifies for this (especially for a CMS related software...).
Brian Clozel
Maybe it might help a *little* when just starting out, but I like to thing I'm a little more accomplished then that.
alex
Wordpress is successful as a product, but an example of 'good code' it most definitely ain't.
thomasrutter
+1  A: 

CakePHP is worth a look too, especially if you need to support PHP4 in addition to PHP5, and the comunity is very active which is good if you need explanation or advice.

John
+5  A: 

I'd strongly suggest to take a look at Yii framework.

  1. Its PHP5 only and purely OOP
  2. Code is perfectly commented (also good if you use Eclipse PDT for intelisence)
  3. I've got lots to learn and seeing how well engineered the framework is teaches me a lot.
  4. The framework makes use of PHP magic methods to dynamically modify/extend behavior of classes (e.g. AR or adding behaviors to classes (sort of multiple inheritance))
  5. Follows MVC way of thinking
  6. Learning curve isn't high

All in all, give a look, its worth it;)

mindeh