views:

132

answers:

5

I am looking for a tutorial / book that guides me to understand the Controll functions and the best practices to write my own controller + Model

Thanks in advance.

+1  A: 

Here is a hopefully helpfull link to an article.

and here is a link to a very descriptive tutorial.

Thariama
+2  A: 

Here are some useful links,

Adeel Ansari
A: 

Why not trying codeigniter? It is a Model View Controller based Framework.

In combination with doctrine its pretty usefull.

Here the link to some codeigniter tutorials: codeigniter tutorials

ITroubs
A: 

You're question basicaly a design patern question, a realy good book about this subject is:

Architect's Guide to PHP Design Patterns

Kdeveloper
A: 

Im sure theres plenty of links been posted to get you started but some important factors in creating an MVC is:

  • Static Registry Class (Store objects and fetch with a global scope)
  • Router (A class that determains the controller/method and params from URI's)
  • Base Controller (just a small abstract class then the users controller can extend)
  • SPL Auto-loading (this will allow users to extend classes such as Model_Database)
  • Structure (you should create directories in accordance with names, I.e Library_session would load /library/session.class.php)
  • Model Abstraction (Account for all types of storage, Database, Disk etc)
  • Error Tracking (Always make sure your logging and capturing errors)

They are just a few tips and ideas you should be thinking about when you create your system.

What you should also do is user other frameworks and build some sample projects, learn how an MVC Framework should be sued, so when your building one you know what the user should expect, then just really study the core structure of the framework.

Take into consideration in PHP the following are usually how MVC Works

  • Controller (this is executed depending on the URI)
  • Model (Accessed from the controller and should be the I/O of Data)
  • View (Templates basically)

but you can work with a MVCL which is (M odel/V iew/C ontroller/L language)

Language is not a specific in the original documentation but its been adopted a few times in regards to the pattern structure, An example of the file structure below will guide you into whats the main purpose of the +L

M: \catalog\model\catalog\product.php
V: \catalog\view\template\product\product.tpl
C: \catalog\controller\product\product.php
L: \catalog\language\english\product\product.php

An example of what company / project uses this method is: OpenCart, AND I HIGHY RECOMMEND YOU LOOKING AT THE ARCHITECTURE!

RobertPitt