List of Figures
Chapter 1. Introducing Zend Framework
Figure 1.1. The organization of a typical PHP file created by a novice interleaves HTML and PHP code in a linear fashion as
the file is created.
Figure 1.2. A typical MVC application separates the code of an application into separate concerns.
Figure 1.3. There are many components in Zend Framework, but we can group them into these six categories for ease of reference.
Figure 1.4. Zend Framework contains lots of components that include everything required to build an enterprise application.
Figure 1.5. The MVC flow in a Zend Framework application uses a front controller to process the request and delegate to a
specific action controller that uses models and views to craft the response.
Chapter 2. Hello Zend Framework!
Figure 2.1. Zend Framework’s Front Controller and MVC components work together to serve a web page. The router and dispatcher
find the correct controller, which builds the page in conjunction with the model and view.
Figure 2.2. A typical Zend Framework application’s directory layout groups the files by their role in the application, so
it is easy to find the file you are looking for.
Figure 2.3. The Hello World application produces the words “Hello World!” in our browser. A minimal Zend Framework application
requires .htaccess, bootstrap, controller, and view files working together to produce this.
Figure 2.4. The interaction of the various Zend Framework classes in an MVC application
Figure 2.5. The FormatCurrency view helper is used to display the correct currency symbol in the correct place.
Chapter 3. Building a website with Zend Framework
Figure 3.1. Mind maps are a good way to brainstorm features for a new website. For this site, we have found that seven main
areas of the website will be required to meet our main goals. The Locations section has been fleshed out the most.
Figure 3.2. PLACES TO TAKE THE KIDS! home page maximizes the amount of space for content while ensuring ease of use.
Figure 3.3. Directory structure of the Places website, showing key files for the home page
Figure 3.4. In order to build the initial pages, the database consists of two tables with a foreign key from Reviews to Places.
Figure 3.5. The unit tests are run from the command line using the phpunit script, which displays the number of tests and
details of any failures.
Figure 3.6. The unit tests are divided into controllers and models. The controllers/AllTests.php and models/AllTests.php scripts
allow each group of tests to be run independently if required.
Chapter 4. Managing the view
Figure 4.1. Multiple templates are used to build up the complete page.
Chapter 5. Ajax
Figure 5.1. Google Suggest was developed in Google’s labs incubator and uses Ajax to provide contextual auto-completion.
Figure 5.2. A simple Ajax example showing an error message while the user types into the text field
Figure 5.3. The application data flow in an Ajax request is controlled by the JavaScript code. A user does something, which
triggers a request, and updates the web page when a response is received.
Figure 5.4. The review feedback system has two buttons to provide feedback.
Chapter 6. Managing the database
Figure 6.1. The Zend_Db_Table components provide a clean method of managing a database table and its associated rows.
Figure 6.2. The Users table for Places contains login information along with demographic information for advertisers.
Figure 6.3. A one-to-many relationship is created via a foreign key (place_id) in the Reviews table.
Figure 6.4. A many-to-many relationship between Places and Users is created via the Reviews table acting as a link.
Figure 6.5. Multiple many-to-many relationships between Places and Users are created via two keys in the Reviews table.
Chapter 7. User authentication and access control
Figure 7.1. The standard HTTP login box provided by a web browser
Figure 7.2. HTTP Authentication showing Zend_Auth methods
Figure 7.3. The logged-in welcome message on the website provides feedback to the user when he’s logged in.
Figure 7.4. The relationship between the pieces of the ACL puzzle
Figure 7.5. Zend_Auth and Zend_Acl work together to provide access to a controller action.
Chapter 8. Forms
Figure 8.1. The results of an empty form submission
Figure 8.2. The results of submitting invalid data
Figure 8.3. Our login form with custom error messages
Figure 8.4. Our login form translated into German
Figure 8.5. Our login redecorated and styled with CSS
Chapter 9. Searching
Figure 9.1. A Zend_Search_Lucene index consists of multiple documents, each containing multiple fields. The data in some fields
is not stored, and some fields may contain data for display rather than searching.
Figure 9.2. The search results page for Places. Each entry has a title that is linked to the indexed page, followed by a summary.
The results are ranked with the most relevant at the top.
Figure 9.3. The Observer design pattern allows us to decouple the search indexing from the model data, making it easy to add
new models to be searched or to change the way we index for searching.
Chapter 10. Email
Figure 10.1. A simplified illustration of the processes involved in sending an email from an HTML form to its recipient’s
email client
Figure 10.2. The initial database structure of our support tracker, requiring the addition of a single Support table alongside
our existing Users table
Figure 10.3. The support-tracker submission form used to send bug or feature requests to the development team
Figure 10.4. Side-by-side comparison of the output of our plain text (left) and HTML (right) support-ticket notification emails
Figure 10.5. Comparing the main difference in email collection between POP3, which works on a simple connect, collect, and
disconnect relationship, and the more capable IMAP
Figure 10.6. The support table with the new reported_by field which allows us to record the details of the sender of the support
email
Chapter 11. Deployment
Figure 11.1. The Places Subversion repository after the first commit
Figure 11.2. The four conflicting variations of the bootstrap.php file after svn update
Figure 11.3. Branches in a Subversion repository
Figure 11.4. Selenium IDE in Table tab with the results of the recording
Figure 11.5. Selenium IDE in Source view with the results of our recording
Figure 11.6. Running our Selenium IDE example unit test using PHPUnit through the Selenium RC Server
Figure 11.7. One failure, due to a typo, on the first run of our unit test
Figure 11.8. The final unit test is successful
Chapter 12. Talking with other applications
Figure 12.1. The GarageSale Mac OS X desktop application, which converses with eBay’s XML-based API using web services
Figure 12.2. The basic web service transaction between two systems using XML-RPC
Figure 12.3. The feed we produced as it appears in the Firefox web browser, together with the XML source
Figure 12.4. The directory structure with our xmlrpc controller file
Figure 12.5. Ecto, the desktop blogging client we’ll be using to make XML-RPC requests, shown editing some Places content.
Figure 12.6. Demonstrating the editPost() method call with the request on the left, the updated article in the middle, and
the response returned from the XML-RPC server on the right.
Figure 12.7. The reviews in our Places application, which we could filter using the Akismet spam-filtering service
Figure 12.8. The results of our REST server query: getPlace on the left and getReviews on the right
Chapter 13. Mashups with public web services
Figure 13.1. Our new Amazon ads shown on the right, and a similar search on Amazon on the left
Figure 13.2. On the right, Flickr images based on article keywords displayed with the article; on the left, the original images
on the Flickr site
Figure 13.3. Our video category page on the right, and the YouTube playlist management page on the left
Figure 13.4. Our video list page on the right, and the YouTube video list management page on the left
Figure 13.5. Our video page on the right, and the original video on YouTube on the left
Chapter 14. Caching: making it faster
Figure 14.1. A database request without caching
Figure 14.2. A database request using caching
Figure 14.3. The decision-making process of a caching system
Chapter 15. Internationalization and localization
Figure 15.1. The text on the German version of Places is translated, but the same view templates are used to ensure that adding
additional languages doesn’t require too much work.
Figure 15.2. Using the locale-aware Zend_Date, we can display the date in the correct language
Chapter 16. Creating PDFs
Figure 16.1. The generated header and introductory text for our PDF report
Figure 16.2. The meeting notes section, showing the use of lines and dashed lines
Figure 16.3. Demonstrating drawing rectangles with our report graph
Figure 16.4. Slices of a circle are drawn in a counter-clockwise direction
Figure 16.5. Demonstrating how rotation works by setting some text at a 10 degree angle
Figure 16.6. The final PDF report page generated by our PDF report generator
Appendix C. Tips and tricks
Figure C.1. A directory structure for a modular Zend Framework application may have its own set of MVC subdirectories.