Here’s a question… If someone comes to you and asks “How do I organise myself in PHP?”, what do you say? In particular, if they are an experienced programmer in other languages but still learning their way around PHP.
Forgetting frameworks for just a moment: in fact despite frameworks, PHP apps are still being written. The question I’m really asking is what application(s) would you point people at as an example for how to do PHP.
These days I find myself pointing people at Eventum, MySQL’s bug tracking application. There are things I personally have “issues” with in the way Eventum is written but those are really just my personal taste. What Eventum represents to me is a safe approach to building PHP applications - reasonably well organised and structured but still a working application, addressing real / common / complex use cases and demonstrably scalable. Also the toolset used to built Eventum and it’s corresponding learning curve is acceptable; other than PHP (and built-in APIs) it’s basically just Smarty, which is well documented.
Given that so many applications have been written in PHP, some extremely successful in terms of popularity, are there any applications you’d be happy to point people at for inspiration? Apps which, despite your personal tastes, you think make a good blueprint for doing PHP? (And if you’ve got the time) Why?
If you liked this blog, share the love:








January 27th, 2006 at 1:17 pm
Speaking of Eventum, it is also a great application by itself, but I still find it quite difficult for non-technical users. The alternatives I found are Flyspray — quite good but still complex — as well as Pesticide and Olate Arctic — both apparently very simple and overall excellent but not quite yet released.
Can anyone suggest another multi-purpose bug tracker that would support multiple projects, be easy for non-technical people and is preferably written in PHP?
January 27th, 2006 at 1:26 pm
I personally think that framweworks are overhyped. Like you cannot write a good application without a framework. On the other hand, I am a firm believer of ‘Seperation of Concerns’ which in case of webbased appplications pretty quicly lead to the MVC/Model II framework/paradigm/whatever…
In general, I see too much that frameworks/applications written for one goal are being reused for another, where other frameworks might have suited better.
You are looking for example applications? In my (humble) opinion, you should state your business case first. Do you need a lot of database access and can the application be seen as ’stand-alone’, or do you need integration aspects? Are there already some components available or do you need to start from scratch? In other words; the question might be simple, the answer (IMHO) depends a lot on the input parameters.
January 27th, 2006 at 1:42 pm
This is the problem I’m having now. I don’t know where to start. Right now I feel that the logical order of the application seems to be correct way to code the application. I think thats what Harry means.
I’m one of those looking for that good blueprint
January 27th, 2006 at 3:32 pm
Excellent post. I have struggled with this in the past, and what has really helped me is applying the DRY principle (don’t repeat yourself). This means, if you have two pieces of code that does roughly the same thing, you should refactor the duplicate code into a single function. This makes it a lot easier to maintain the code. The same goes for database design. If you have duplicate data in the database, you should refactor that data into a new table and relate to that data using a primary key (id field).
Refactoring and the DRY principle go hand in hand, if you want to learn more about refactoring, I recommend reading Martin Fowler’s book:
http://www.amazon.com/exec/obidos/tg/detail/-/0201485672?v=glance
One more thing: do not add abstraction unless you know that it is necessary. If you add too much abstraction (over engineering) the code can become unnecessarily complex.
I like to think of code as a human skeleton, and the abstraction as the joints. Abstraction, like joints, allows your code to be flexible and adapt to change. Filling the code with too much abstraction is like adding too many joints to a skeleton - you would be able to adapt to any kind of change and accomplish all kinds of weird things, but you would have no structure to function properly and efficiently (can you imagine trying to walk around with twenty joints in your legs?).
Hope that helps.
January 27th, 2006 at 4:48 pm
I agree that frameworks are overhyped, especially the MVC architecture. That is just my personal opinion though. I do use frameworks, but it depends on the project.
I’d say a great example of an application in PHP is WordPress. While the code is procedural, the entire system is extremely easy to work with, code wise. Everything is straight forward and not hidden in some remote object.
I think PunBB is also well put together, even though it’s procedural.
January 27th, 2006 at 6:30 pm
The best code I’ve ever seen is the Drupal CMS: http://drupal.org. It’s purely functional, using no object-oriented code. For what it needs to do it’s simply great code.
January 27th, 2006 at 6:37 pm
That’s a very good point, particularly when it comes to looking at details.
Regarding Eventum, think it represents a fairly broad set of apps but in a general sense: it’s data driven, has user authentication / access control (down to feature level permissions), reporting, some degree of “groupware” etc. But this is definately in the realm of “data driven” with the CVS integration aspect giving it a particular slant.
By contrast, content management is a different space, as one example.
To that extent PHP has a lot of “wealth” available in that pretty much every typical web application has been done in, in some form or other. There should at least be an example to look at - whether you really want to is another question.
That said I think the way Eventum does stuff on a general level makes a pretty good basis for organising code, on the ground that you can’t go horribly wrong with this style. Stuff like keeping the page controllers simple and procedural, while having them coordinate classes and objects or how they handle configuration is all “safe” to my mind.
Sure Eventum could probably be cleaner, sexier etc. plus this is purely PHP4. Meanwhile copying the code too literally might not be smart - there’s even use of the old HTTP_GET_VARS etc. in there.
But the general way it’s organised makes a pretty sane way to go I think; low risk, faily predictable time scales, generally maintainable.
Exactly.
January 27th, 2006 at 6:55 pm
I think Wordpress definately needs examining for how to “do” an extensible application in a way that people seem to like (given massive number of wordpress plugins). It also seems to be popular for “embed-ability” - fairly easy to plugin to your site alongside your other code.
For me Drupal needs looking at for how to “do” modules-stlye “frameworks”.
January 27th, 2006 at 7:12 pm
SugarCRM, ( http://www.sugarcrm.com ) I always thought was a good example, perhaps the actual code isnt that great, but from a user POV seems pretty well done.
January 27th, 2006 at 7:30 pm
[…] Harry, thanks for the praise for Eventum. This is mainly the result of my work and Bryan Alsdorf at MySQL, even though I’m no longer with MySQL AB anymore. We do agree with you on the aspects of making the page controllers as simple as possible, and also trying to let the code be as simple as possible, but still easy to maintain and change. […]
January 27th, 2006 at 7:32 pm
By the way, bugs.mysql.com is not powered by Eventum. That runs on top of some pretty old and hacked around code from Jim Winstead. They are planning on switching to Bugzilla eventually.
–Joao
January 27th, 2006 at 8:07 pm
bugs.mysql.com uses the php.net’s php-bug-web code which Jim Winstead has hacked even more stuff into.
January 28th, 2006 at 6:38 am
[…] Por eso Harry Fuecks se pregunta, si debería establecerse un “PHP Blueprints” como el que tiene, por ejemplo, Java. […]
January 29th, 2006 at 10:24 pm
Off the top of my head, the Vanilla forum and MediaWiki are good examples of PHP apps.
January 30th, 2006 at 12:18 am
Having looked at many PHP Groupware/Blog/Portal CMS tools - I settled on geeeklog several years ago and found it very easy to understand and learn PHP Development. It’s evolved nicely over the past couple years into a very flexible framework for application development (plugins) with it’s API and underlying flexible user role, permission and library of common functions.
It’s not a pure OO framework but does have a mixture of classes and procedural code that is pretty easy to follow. GL is also one of the more security oriented solutions available.
January 30th, 2006 at 12:20 am
Doh - this site needs a preview and time limited edit for comments.
January 30th, 2006 at 4:31 am
I decided on blog software based on the idea that object-oriented classes are a good idea. I downloaded a number of packages, grepped for the word “class” and decided on pLog based on the results.
http://www.reiersol.com/plog/blog/pretty_high_potency/open_source/2005/08/16/blog_me_tender
January 30th, 2006 at 5:01 am
Hmm…. I have seen some very bad design in OO, and I have seen some very good designed imperative programs. The use of classes does defintely not guarantee quality (at all!!!)
January 30th, 2006 at 6:41 am
Point taken. It’s in development at the moment.
January 30th, 2006 at 3:21 pm
OOP is just imperative programming with diminished “side-effects” (from a functional point of view).
http://en.wikipedia.org/wiki/Imperative_programming
You are confusing OOP with using classes ;)
And it’s like saying … I saw some badly written structured code, and in fact, using standard structures (instead of my conditional GOTOs) in your program does not guarantee quality (at all!!!).
You might want to think more about that.
Somehow, PHP programmers are one of the last kind standing and arguing that OOP doesn’t matter.
January 31st, 2006 at 7:35 am
I’d highly recommend taking a look at the source code of Gallery 2.
It’s well designed, the code is very clean and it shows that you can use modern programming patterns in PHP as you’d use them in Java or the like.
Even if it is all OOP, it’s not the best source to learn about the latest OO features of PHP5 since it’s all PHP4.1+ compliant in Gallery 2.
January 31st, 2006 at 12:09 pm
Hello
I try to learn OOP. Not how to build a class but how to design.
Now, I ve been looking at Mojavi 2.0 (PHP 4). I recommend it for whose would like to learn by themself. I like the Loggin Lib of Mojavi.
Maybe Unit testing (with SimpleTest or PHP Unit) is a way of improving developpemnt cycle.
Sorry for my English ;-)
Hervé
February 3rd, 2006 at 11:29 am
has anybody taken a look at seagull this has a very good code base for developing MVC-like applications in PHP and the code is well written (IMHO)