Templates are broken out so that elements can be accessed and used by javascript or php equally.
Thats a good practice, makes everything far more reusable.
But basically, every framework I’ve seen was written first then Ajax was added later. This is being written with ajax in mind from the get go. That’s why the system organizes itself into an event based design - because Javascript is an Event Driven OOP language. It’s one thing to provide callbacks for js, quite another to provide callbacks that don’t incur unneeded overhead. For that to happen the framework has to be written with minimal service starting in mind from the get go.
I think AJAX should be added on later, personally. Otherwise you end up coupling controllers or PHP code directly to JavaScript, no?
For instance, in my applications, everything is always done at the controller action, no more do I instantiate Locale, DB or anything in the bootstrap.
My views, are like yours. The resulting HTML page returned to user-agent is a composition of many parts.
For that reason, I prefer to implement my regular actions, then later implement AJAX actions, REST actions, CLI actions, etc. Any request, regardless of where it comes from goes through the same index.php
This goes all the way down to the heart of the system. The framework can respond to a validation query on a field without starting the database because the event is doesn’t need user authentication. I’ve yet to see a framework, particular a CMS framework, that doesn’t assume that every connection requires at least one database lookup and starts the database immediately on start.
I have never had to instantiate a DB object to validate incoming data. Validation is a distinct operation from DAL. It’s business logic usually and thus should be done in the model layer not in a database. This is common practice, except when you use a ORM like Doctrine, which I believe has validation services built in (bloat overhead if you ask me).
CMS are a different story, because ones like Drupal store everything in the database. Routing tables, mappping URI to pages for instance, so by design it needs a DB almost immediately upon loading. Personally I opt to store routing files/maps in files, so a DB isn’t required after the expected controller and action has been invoked, avoiding senesless overhead.
Cheers,
Alex