You are previewing Zend Framework 1.8 Web Application Development.
O'Reilly logo
Zend Framework 1.8 Web Application Development

Book Description

Design, develop, and deploy feature-rich PHP web applications with this MVC framework

  • Create powerful web applications by leveraging the power of this Model-View-Controller-based framework

  • Learn by doing – create a "real-life" storefront application

  • Covers access control, performance optimization, and testing

  • Best practices, as well as debugging and designing discussion

In Detail

The Zend Framework has a flexible architecture that lets you build modern web applications and web services easily. The MVC components make the maintenance and testing of your applications easier. However, it is not only an MVC framework for developers. It also provides an easy-to-use high-quality component library that is designed to be used the way you want, picking up specific components without requiring the use of whole framework.

It's easy to get started and produce a powerful and professional looking web site when you've got this book to hand. Taking you through a real-life application, it covers the major Zend Framework components, as well as throwing light on the best practices and design issues faced when building complex MVC applications.

This book takes you through detailed examples as well as covering the foundations you will need to get the most out of the Zend Framework. From humble beginnings you will progress through the book and slowly build upon what you have learned previously. By the end, you should have a good understanding of the Zend Framework, its components, and the issues involved in implementing a Zend Framework based application.

Table of Contents

  1. Zend Framework 1.8 Web Application Development
  2. Credits
  3. About the Author
  4. About the Reviewers
  5. Preface
    1. Brief history and future developments
    2. What is it and why use it
      1. Licensing
      2. Quality
      3. Simplicity
      4. Flexibility
      5. Out-of-the-box features
      6. Community
    3. What this book covers
    4. Who this book is for
    5. Conventions
    6. Reader feedback
    7. Customer support
      1. Downloading the example code for the book
      2. Errata
      3. Piracy
      4. Questions
  6. 1. Creating a Basic MVC Application
    1. Overview of MVC architecture
    2. Setting up the environment
    3. Installation
    4. Creating the project structure
    5. Application directory structure
    6. Bootstrapping
      1. The index file
      2. Application configuration
      3. The bootstrap file
    7. Your first controller
      1. The Action Controller
        1. Subclassing
        2. Initialization
        3. Actions
        4. The standard router
        5. Utility methods
          1. _forward utility method
          2. _redirect utility method
        6. Action Helpers
    8. Your first view
      1. View directories
      2. Creating a view
      3. View Helpers
        1. URL View Helper
      4. View customization
    9. Handling errors
    10. Summary
  7. 2. The Zend Framework MVC Architecture
    1. Zend framework MVC overview
      1. What is a request
      2. Request handling
      3. Abstractness of MVC components
    2. The Front Controller
      1. Design
      2. Defaults
      3. Using the Front Controller
        1. Invocation parameters
        2. Options
        3. Modules, controllers, and actions
        4. MVC component customization
        5. Plugins
    3. The router
      1. Design
      2. Defaults
      3. Using the router
        1. Zend_Controller_Router_Route
        2. Zend_Controller_Router_Route_Static
        3. Zend_Controller_Router_Route_Regex
        4. Zend_Controller_Router_Route_Hostname
        5. Zend_Controller_Router_Route_Chain
        6. Zend_Config
    4. The Dispatcher
      1. Design
      2. Request dispatching
      3. Using the Dispatcher
    5. The Request object
      1. Design
      2. Defaults
      3. Using the Request object
        1. The HTTP Request object
    6. The Response object
      1. Design
      2. Defaults
      3. Using the Response object
    7. Summary
  8. 3. Storefront Basic Setup
    1. Getting started
      1. Software requirements
      2. Coding standards
    2. The Storefront requirements
    3. The Storefront overview
    4. Basic structure and setup
      1. The directory structure
      2. Bootstrapping with Zend_Application
        1. Zend_Application basics
        2. Bootstrapping the storefront
        3. Zend_Application configuration
          1. Configuration options
            1. Autoloader namespaces
            2. PHP settings
            3. Bootstrap class path
            4. Bootstrap resource plugins
            5. Using an array
            6. Environment specific configuration
        4. The bootstrap class
          1. Bootstrap resource execution order
          2. Bootstrap abstract class
        5. Creating the bootstrap resources
          1. Locale initialization
          2. View initialization
            1. Instantiating Zend_View
            2. Doctype and encoding
            3. Adding metadata
            4. Adding CSS stylesheets
            5. Setting the document title
        6. Bootstrapping complete
      3. The basic layout
        1. A little task for you
    5. Building the Storefront
    6. The Storefront database
      1. Database installation
        1. Product table
        2. ProductImage table
        3. Category table
        4. The user table
      2. Introducing Zend_Db
        1. Adding Zend_Db to the Storefront
    7. Logging and debugging
      1. Zend_Debug
      2. Zend_Log
        1. Adding Zend_Log to the Storefront
        2. Using the logger
        3. Database profiling with Zend_Log
    8. Summary
  9. 4. Storefront Models
    1. Models in the Zend Framework
    2. Model design
      1. The application stack
      2. Fat Model Skinny Controller
        1. Fat Controller
        2. Fat Model
      3. Model design strategies
        1. Direct inheritance
        2. Has-a relationship (composition)
        3. Domain Model
      4. Further reading
    3. Storefront Models
      1. Model Resources
      2. Managing Model Resources
      3. Model Resource data sources
        1. Model Resource Items
        2. Resource Item business logic
    4. Loading Models and Resources
      1. Zend_Loader_Autoloader_Resource
        1. Resource Autoloading
    5. The SF Library
    6. Summary
  10. 5. Implementing the Catalog
    1. Getting started
    2. Creating the Catalog Model and Resources
      1. Catalog model skeleton
        1. Naming conventions
        2. Catalog methods
      2. Catalog Model Resources
        1. Zend_Db_Table
          1. Zend_Db_Table basic usage
          2. Zend_Db_Table relationships
        2. Model Resource Items
          1. SF_Model_Resource_Db_Table_Row_Abstract
          2. Creating the Model Resource Items
      3. Implementing the Catalog Model
        1. Model Resource interfaces
        2. Model Resource implementation
          1. Category Model Resource
          2. Category Resource Item
          3. Product Model Resource
          4. Product Resource Item
          5. ProductImage Resource Item
      4. Catalog Model
    3. Loading Models and other assets
      1. Configuring the Autoloader
      2. The Zend_Db_Table bug
    4. Creating the Catalog Controllers
      1. CategoryController
        1. Action Stack Front Controller Plugin
      2. CatalogController
      3. Storefront routes
    5. Creating the Catalog Views
      1. Category views
      2. Catalog views
      3. Catalog View Helpers
        1. View Helper creation
          1. Best practices
        2. Creating the Catalog View Helpers
    6. Building and running the storefront
    7. Summary
  11. 6. Implementing User Accounts
    1. Creating the user model and resources
      1. User model
      2. User Model Resources
    2. Creating the Customer Controller
    3. Zend_Form
      1. Basic forms
        1. What is a Form?
        2. Creating a Form
      2. Customizing Zend_Form's output
        1. The Decorator pattern
        2. Zend_Form's Decorators
          1. Form elements
          2. The Form
          3. Display Groups and Subforms
        3. Fixing the login forms HTML
      3. The User forms
        1. A Typical Form element
        2. Custom validators
          1. Unique email validator
          2. Password verification validator
          3. Using custom validators, filters, and decorators
        3. Base form decorators
        4. Specializing forms
    4. Creating the Customer Views
    5. Building the application
    6. Summary
  12. 7. The Shopping Cart
    1. Creating the Cart Model and Resources
      1. Cart Model
        1. Cart Model interfaces
        2. Cart Model implementation
      2. Cart Model Resources
      3. Shipping Model
    2. Creating the Cart Controller
    3. Creating the Cart Views and Forms
      1. Cart forms
        1. Add form
        2. Table form
        3. SF_Form_Abstract
      2. Cart View Helper
      3. Cart View scripts
        1. Cart view.phtml
        2. Cart _cart.phtml
        3. Layout main.phtml
        4. Catalog index.phtml
        5. Catalog view.phtml
    4. Summary
  13. 8. Authentication and Authorization
    1. Authentication versus Authorization
    2. Authentication with Zend_Auth
      1. Zend_Auth
        1. Authentication adapters
        2. Authentication results
        3. Identity persistence
      2. Authentication Service
      3. Customer Controller
      4. Authentication View Helper
      5. Other Authentication Service elements
    3. Authorization with Zend_Acl
      1. Zend_Acl introduction
      2. ACL in MVC
        1. Using a centralized global ACL
        2. Using module specific ACL's
        3. ACL in the Domain layer
      3. Model based ACL
        1. The Storefront ACL
        2. The Storefront roles
        3. The Storefront resources
        4. The new base model
        5. Securing the User Model
      4. Non-Model ACL
      5. Unit testing with ACL
    4. Summary
  14. 9. The Administration Area
    1. What is an administration area?
      1. Implementation options
    2. Implementing the storefront administration area
      1. Admin Route
      2. Admin context Front Controller plugin
      3. Admin layout
      4. Admin controller
    3. Catalog management
      1. Adding products
        1. Product add form
          1. Sharing form elements
          2. Custom filters
        2. Catalog Model
        3. Catalog Controller
    4. Securing the administration area
      1. ACL action helper
        1. Securing the Admin functions
      2. Catalog Model ACL
    5. Summary
  15. 10. Storefront Roundup
    1. Using multiple modules
      1. Setup
      2. Configuring Zend_Application
      3. Bootstrapping modules
      4. Module specific configuration
      5. Sharing common elements
    2. Services
      1. Services for cross module communication
      2. Services for extending model behavior
    3. Summary
  16. 11. Storefront Optimization
    1. General optimizations
      1. Opcode caching
      2. Path optimizations
      3. Requires and includes
      4. Standard caches
        1. Plugin loader cache
        2. Db table cache
    2. Dispatching optimizations
    3. Caching
      1. Zend_Cache
      2. Model data caching
        1. Basic class caching
        2. Model cache integration
          1. The abstract cache class
          2. The concrete cache class
          3. Model abstract modifications
          4. Caching the product listing
          5. Saving new data
          6. Fixing Zend_Db_Table_Row exceptions
    4. Summary
  17. 12. Testing the Storefront
    1. What is testing?
    2. PHPUnit and Zend_Test setup
      1. PHPUnit setup
      2. Zend_Test setup
      3. Handling the database
    3. Writing tests
      1. Running tests
        1. Adding tests to the build
    4. Testing the Customer Controller
      1. Running the Customer Controller test
    5. Common problems
    6. Summary
  18. A. Installing Supporting Software
    1. Installing PHPUnit
    2. Installing Xdebug
      1. Windows installation
      2. Linux based installation
      3. OSX Installation
      4. Configuration
    3. Installing Apache Ant
      1. Windows installation
      2. Linux installation