kiwi_nz wrote:I guess this is the more salient point. The MVC is a pattern that is not wholeheartedly embraced bye everyone. I guess it comes down to maintainability.
Right. And MVC is not the only way to produce maintainable code. And maintainability is not the only criteria in deciding on an architecture. I think it is the best solution, but I naturally tend to build my Model or View code first and my Controller code last. That make MVC work better for me than for people who tend to write Controller code first and then build out.
kiwi_nz wrote:My background is not in PHP but rather in Django/Python. However what I have noticed about PHP is that trying to understand someone else's code base and I am looking at a popular PHP project and I see they have made no attempt to separate presentation from business logic which I guess is more the salient point rather than whether it is MVC or not.
Yes, exactly. And I agree with you on the importance of that layer separation. That's how I build my apps. However, if you are willing to accept the maintenance and growth problems, then writing Transaction Scripts can be acceptable especially in web apps. The reason is because the business logic is usually fairly simple and is focused on quickly generating some simple data to build a web page. Given how PHP can be broken up into pages, the result is a reasonably organized and readable application for most websites. I think there is a gap between what we might like and what is actually bad.
kiwi_nz wrote:Perhaps I should have titled this PHP/CGI vs other ways of doing PHP. I understand the PHP has ways of embedding html within .html templates? Looking at my current PHP project I see they have no templates but everything is dynamically constructed. Ugggh. Not at all the way I am used to working. Is CGI still very popular or is it being superseded in favour of some other PHP framework??
First, one way that PHP is different from other languages is that it is both a templating language and an application programming language. This is due to PHP being embedded in the web server, unlike regular languages. PHP programmers keep the difference straight in their heads, so where you see a mix of domain and presentation there may actually be clear dependencies. And it is the dependencies that are most important -- not just that the code is structured in a way you like.
You should take a look at one of the ports of Django templates to PHP:
http://wiki.github.com/speedmax/h2o-php/
http://www.beberlei.de/calypso/
I think my bigger question is: What is your question? Are you really interested in opinions about PHP architecture? Do you just want to whinge about how crappy you think the code is in some PHP projects? Or do you want to be able to write Django style code in PHP? Something else?