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