Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 1 | ##################### |
| 2 | Model-View-Controller |
| 3 | ##################### |
| 4 | |
| 5 | CodeIgniter is based on the Model-View-Controller development pattern. |
| 6 | MVC is a software approach that separates application logic from |
| 7 | presentation. In practice, it permits your web pages to contain minimal |
| 8 | scripting since the presentation is separate from the PHP scripting. |
| 9 | |
| 10 | - The **Model** represents your data structures. Typically your model |
| 11 | classes will contain functions that help you retrieve, insert, and |
| 12 | update information in your database. |
| 13 | - The **View** is the information that is being presented to a user. A |
| 14 | View will normally be a web page, but in CodeIgniter, a view can also |
| 15 | be a page fragment like a header or footer. It can also be an RSS |
| 16 | page, or any other type of "page". |
| 17 | - The **Controller** serves as an *intermediary* between the Model, the |
| 18 | View, and any other resources needed to process the HTTP request and |
| 19 | generate a web page. |
| 20 | |
| 21 | CodeIgniter has a fairly loose approach to MVC since Models are not |
| 22 | required. If you don't need the added separation, or find that |
| 23 | maintaining models requires more complexity than you want, you can |
| 24 | ignore them and build your application minimally using Controllers and |
| 25 | Views. CodeIgniter also enables you to incorporate your own existing |
| 26 | scripts, or even develop core libraries for the system, enabling you to |
| 27 | work in a way that makes the most sense to you. |