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?
-
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!
alex : I think because it is abundant with singletons... just my guess.IonuČ› G. Stan : 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. -
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.
-
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.
stesch : 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. -
Joomla is not exactly an example of good php code. Mediawiki, the software used by the wikipedia is pretty much better.
alex : 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. -
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
-
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.
Brian Clozel : Wordpress, seriously? alex is asking about good practices and patterns. I'm not sure Wordpress qualifies for this (especially for a CMS related software...).alex : Maybe it might help a *little* when just starting out, but I like to thing I'm a little more accomplished then that.thomasrutter : Wordpress is successful as a product, but an example of 'good code' it most definitely ain't. -
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.
-
I'd strongly suggest to take a look at Yii framework.
- Its PHP5 only and purely OOP
- Code is perfectly commented (also good if you use Eclipse PDT for intelisence)
- I've got lots to learn and seeing how well engineered the framework is teaches me a lot.
- 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))
- Follows MVC way of thinking
- Learning curve isn't high
All in all, give a look, its worth it;)
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.