2. Examples from a demo blogging application named Postr are
used throughout this presentation. You can view, download, or
fork the demo web application on GitHub:
http://github.com/bradley-holt/postr
3. Zend_Tool
Automated scaffolding of project and project components
Used in creating the demo application, Postr
Referenced throughout this presentation
6. Front Controller
All HTTP requests for the application go through
one script.
Apache’s rewrite module (or equivalent) makes this
happen.
See:
Front Controller pattern
public/index.php
public/.htaccess
8. Con guration
Default con guration is in application/configs/application.ini
Allows for con guration sections; for example:
• production
• staging
• testing
• development
Sections can inherit from other sections
See:
application/con gs/application.ini
9. Name the Project
Default application class name pre x is Application_.
zf change application.class-name-prefix Postr_
10. Updated Con guration
Added to application/configs/application.ini:
[production]
appnamespace = "Postr_"
See:
application/con gs/application.ini
11. Model-View-Controller (MVC)
Composite of several design patterns
Isolates domain logic from input and presentation
Model: domain logic
View: presentation layer
Controller: interprets input and passes it to the
Model; provides Model data to the View
See:
Model-view-controller
application/models/
application/views/
application/controllers/
12. Zend_Layout
Implementation of the Two Step View pattern
Allows for consistent layout across multiple pages
Easier to manage than “includes”
See:
Zend_Layout
Two Step View
15. Controllers
Connects the Model and the View
Contains one or more actions
URL based routing typically decides what controller
and action to execute:
:controller/:action
Custom routing options available
16. View Scripts
PHP templates
No domain logic please!
Default suffix of .phtml
One view script per controller action (by default)
22. Zend_Test
Functional (end-to-end) testing of controllers
Simulates HTTP requests to the application
No web server required
Also provides a DB testing facility
See:
Zend_Test
Functional Test
tests/application/controllers/EntryControllerTest.php
23. Models
Models are speci c to your domain
No such thing as one-size- ts all models
No Zend_Model
However, some useful patterns have emerged
32. Load DB Schema
Project-speci c and not built-in to Zend Framework:
mkdir -p data/db
php scripts/load.sqlite.php
See:
scripts/load.sqlite.php
scripts/schema.sqlite.sql
33. Create DB Tables from
the Database
zf create dbtable.from-database
34. Entry and Entry Tag
DB Tables
application/
models/
DbTable/
Entry.php
EntryTag.php
See:
application/models/DbTable/Entry.php
application/models/DbTable/EntryTag.php
35. Data Mapper
Keeps your domain logic isolated from your
database implementation
Domain objects should not directly use data
mappers
See:
Data Mapper
38. Zend_Paginator
Pagination for database or any arbitrary data
Several adapters available:
• Array
• DbSelect
• DbTableSelect
• Iterator
• Null
• Write your own in order to paginate domain objects
See:
Zend_Paginator
41. Zend_Date
Manipulate dates and times
Useful for date and time calculations
Allows for input from and output to various formats
Used as a domain object in the Postr demo application:
• Entry Updated
• Entry Published
See:
Zend_Date
application/models/Entry.php
42. Zend_Markup
Renders BBcode or Textile markup into HTML or other formats
Extensible so may see other markup languages in the future
Used in the Postr demo application:
• Entry Content and Entry Summary are stored as Textile
markup
• Entry Content and Entry Summary can optionally be
retrieved as HTML
See:
Zend_Markup
BBCode
Textile
application/models/Entry.php
43. Zend_Navigation
Create menus, breadcrumbs, links, and sitemaps
Used to create the menu navigation in the Postr demo
application
See:
Zend_Navigation
application/Bootstrap.php
application/layouts/scripts/header.phtml
44. Controller Plugins
Allows developers to hook into various events during the
controller process:
• routeStartup()
• dispatchLoopStartup()
• preDispatch()
• postDispatch()
• dispatchLoopShutdown()
• routeShutdown()
See:
Controller Plugins
application/plugins/RouteContext.php
46. Credits
Author
Bradley Holt
Layout & Design
Jason Pelletier
This presentation licensed under
Creative Commons—Attribution 3.0 United States License.