tags:

views:

49

answers:

1

In a few weeks, I will guide some of our trainees through a customer project, where they have to build a small web application in php. My idea is to setup a small MVC structure for them to learn oop and mvc and to assure code quality. How would you do this? We have no special requirements, just php and mysql. Would you use a template system like twig or just use phtml files like magento does? Would you use some ORM like propel oder just pdo? Any suggestions welcome.

A: 

Here is an excellent startup tutorial on MVC structure at phpro.org:

Would you use a template system like twig or just use phtml files like magento does?

Above tutorial uses a method for templating system. But you can also modify/improve the templating mechanism as per you needs that you think is more flexible.

Would you use some ORM like propel oder just pdo?

For serious mvc framework development, it is better to use them. But for educational purpose that isn't a requirement but an additional step if you want to take.

Sarfraz
Downvote, cause given tutorial has nothing to do with MVC. There is no view, the model is bad designed and the controller is doing what he shouldn't do.
Crozin
@Crozin: So you expected a perfect mechanism beyond basics for a newbie? It is excellent reading in my view. I would like to see your solution too.
Sarfraz
I except a basic implementation of MVC in article about MVC. I can't find a View layer in that article (HTML template **is not** a view), I can't find any model interface (like `Paginable`, `Sortable` etc.). Data sources (like SQL Database) is accessible directly from the controller. In other words: that article shows some "separation of application layers", however it's not MVC (it **does not** meat goals of MVC pattern).
Crozin
You wanted to see some simple implementation, so here it is: http://ideone.com/i6kr4 (index.php) http://ideone.com/gHrjk (list-template.php) http://ideone.com/E9LAW (table-template.php) http://ideone.com/Rg82I (pagination-partial.php). Please note that it was written some time ago for similar discussion, so it's very primitive.
Crozin
@Crozin: You are still comparing basic tutorial with full-featured and advanced one :) Your links should prove useful to OP possibly.
Sarfraz
MVC itself ain't trivial so tutorials about it cannot be so simple. Please note that this tutorial and my code are *completely different* (those two codes work and act different on many levels).
Crozin