Difference between revisions of "Model-View-Controller"
(→Models, Views, Controllers Defined) |
(→Models, Views, Controllers Defined) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
== MVCnPHP == | == MVCnPHP == | ||
− | MVCnPHP, Model-View-Controller iN PHP, is a simplified MVC implementation based very loosely off of Phrame and Struts with all the garbage taken out. If you are Struts fan, don't take too much offense as I believe it is a good tool but it aims at doing more than a simple MVC implementation. Phrame similarly is a Struts-like MVC implementation that share many of the same problems in Struts. Since it's release back in 2003 it has kept it's simplicity and has significantly improved performance. From this point on I'm going to assume you know what MVC and are eager to learn how to implement MVCnPHP in your application. | + | MVCnPHP, Model-View-Controller iN PHP, is a simplified MVC implementation based very loosely off of Phrame and Struts with all the garbage taken out. If you are Java programmer and a Struts fan, don't take too much offense as I believe it is a good tool but it aims at doing more than a simple MVC implementation. Phrame similarly is a Struts-like MVC implementation that share many of the same problems in Struts. I wrote MVCnPHP back in 2003 because, in my opinion, there wasn't a bare bones, intuitive MVC implementation in PHP. Since it's release back in 2003 it has kept it's simplicity and has significantly improved performance. From this point on I'm going to assume you know what MVC and are eager to learn how to implement MVCnPHP in your application. |
== Models, Views, Controllers Defined == | == Models, Views, Controllers Defined == | ||
Line 12: | Line 12: | ||
#[[MVCnPHP Installation]] | #[[MVCnPHP Installation]] | ||
− | #[[ | + | #[[MVCnPHPController|Using the Controller]] |
#[[Building a View]] | #[[Building a View]] | ||
− | #[[Understanding the MVCnPHP Configuration File]] | + | #[[MVCnPHPConfig|Understanding the MVCnPHP Configuration File]] |
− | #[[Building a Command]] | + | #[[MVCnPHPCommand|Building a Command]] |
#[[Using Forwards]] | #[[Using Forwards]] |
Latest revision as of 15:58, 21 September 2006
Model-View-Controller
If you don't know what it is, you better ask somebody. Separating the user interface from business logic from data access is a framework essential and is key to making your application easier to maintain. Most MVC implementations break code into atomic units of work that encourage reuse and maintainability. Geeklog 2 uses MVCnPHP to accomplish this.
MVCnPHP
MVCnPHP, Model-View-Controller iN PHP, is a simplified MVC implementation based very loosely off of Phrame and Struts with all the garbage taken out. If you are Java programmer and a Struts fan, don't take too much offense as I believe it is a good tool but it aims at doing more than a simple MVC implementation. Phrame similarly is a Struts-like MVC implementation that share many of the same problems in Struts. I wrote MVCnPHP back in 2003 because, in my opinion, there wasn't a bare bones, intuitive MVC implementation in PHP. Since it's release back in 2003 it has kept it's simplicity and has significantly improved performance. From this point on I'm going to assume you know what MVC and are eager to learn how to implement MVCnPHP in your application.
Models, Views, Controllers Defined
Models are the data structures your PHP application will use and they represent the core business components of your business. So, for example, you may very well have models that represent users, accounts and transactions. Models are ideally simple PHP classes that are made up of members and their accessors (i.e. getters/setters). Views are mechanisms used to render one or more models to a users. Views are the visual component and in most basic web development terms are represented by a single screen. A controller manages program execution between models and views and commands. What's this command thing? Commands are implementation of the command design pattern. Commands are simply used to represent actions. Thus it is quite typical in MVC implementations to have a view submit data to a command which in turn requests another view to be show all being dispatched by the controller. Is all this fuzzy? No worry, let's look at each piece of MVCnPHP in more detail.