1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="learning.quickstart.intro">
4 <title>Zend Framework & MVC Introduction</title>
6 <sect2 id="learning.quickstart.intro.zf">
7 <title>Zend Framework</title>
10 Zend Framework is an open source, object oriented web application framework for
11 <acronym>PHP</acronym> 5. Zend Framework is often called a 'component library', because
12 it has many loosely coupled components that you can use more or less independently. But
13 Zend Framework also provides an advanced Model-View-Controller (<acronym>MVC</acronym>)
14 implementation that can be used to establish a basic structure for your Zend Framework
15 applications. A full list of Zend Framework components along with short descriptions may
16 be found in the <ulink
17 url="http://framework.zend.com/about/components">components overview</ulink>. This
18 QuickStart will introduce you to some of Zend Framework's most commonly used components,
19 including <classname>Zend_Controller</classname>, <classname>Zend_Layout</classname>,
20 <classname>Zend_Config</classname>, <classname>Zend_Db</classname>,
21 <classname>Zend_Db_Table</classname>, <classname>Zend_Registry</classname>, along
22 with a few view helpers.
26 Using these components, we will build a simple database-driven guest book application
27 within minutes. The complete source code for this application is available in the
35 url="http://framework.zend.com/demos/ZendFrameworkQuickstart.zip">zip</ulink>
42 url="http://framework.zend.com/demos/ZendFrameworkQuickstart.tar.gz">tar.gz</ulink>
48 <sect2 id="learning.quickstart.intro.mvc">
49 <title>Model-View-Controller</title>
52 So what exactly is this <acronym>MVC</acronym> pattern everyone keeps talking about, and
53 why should you care? <acronym>MVC</acronym> is much more than just a three-letter
54 acronym (<acronym>TLA</acronym>) that you can whip out anytime you want to sound smart;
55 it has become something of a standard in the design of modern web applications. And for
56 good reason. Most web application code falls under one of the following three
57 categories: presentation, business logic, and data access. The <acronym>MVC</acronym>
58 pattern models this separation of concerns well. The end result is that your
59 presentation code can be consolidated in one part of your application with your business
60 logic in another and your data access code in yet another. Many developers have found
61 this well-defined separation indispensable for keeping their code organized, especially
62 when more than one developer is working on the same application.
66 <title>More Information</title>
69 Let's break down the pattern and take a look at the individual pieces:
73 <inlinegraphic width="321" scale="100" align="center" valign="middle"
74 fileref="figures/learning.quickstart.intro.mvc.png" format="PNG" />
80 <emphasis>Model</emphasis> - This is the part of your
81 application that defines its basic functionality behind a set of
82 abstractions. Data access routines and some business logic can be defined in
89 <emphasis>View</emphasis> - Views define exactly what is
90 presented to the user. Usually controllers pass data to each view to render
91 in some format. Views will often collect data from the user, as well. This
92 is where you're likely to find <acronym>HTML</acronym> markup in your
93 <acronym>MVC</acronym> applications.
99 <emphasis>Controller</emphasis> - Controllers bind the whole
100 pattern together. They manipulate models, decide which view to display based
101 on the user's request and other factors, pass along the data that each view
102 will need, or hand off control to another controller entirely. Most
103 <acronym>MVC</acronym> experts recommend <ulink
104 url="http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model">keeping
105 controllers as skinny as possible</ulink>.
111 Of course there is <ulink url="http://ootips.org/mvc-pattern.html">more to be
112 said</ulink> about this critical pattern, but this should give you enough
113 background to understand the guestbook application we'll be building.