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

Book Description

PHP developers can create more powerful applications using the flexibility of Zend Framework 2. This book will extend your capabilities through a totally practical course culminating in the creation of a social network.

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

  • Learn by doing; create a social network from design to deployment

  • Written in a framework and the API-centric approach to simplify the process of learning

  • In Detail

    Zend Framework 2 has a flexible architecture that lets us build modern web applications and web services easily. It also provides an easy-to-use, high quality component library that is designed to be used the way you want.

    It's easy to get started and produce a powerful and professional looking website with Zend Framework 2 Application Development. Exploring real life applications, we will explore the Zend Framework 2 components, as well as throwing some light on best practices and design concerns faced when building complex MVC applications.

    Zend Framework 2 Application Development is a hands-on guide to building your application.

    We will explore the components of this new version of the framework and discover how to use each component, the options available, and how to get the most from each component. Whilst learning everything you need to know, we’ll even create our own social network.

    We will also learn to engineer an application using an API-centric approach, broadly used today to build applications that work seamlessly on desktops, mobiles and tablets. We will learn how to filter and validate data, interact with databases to retrieve and store data, handle and manipulate file uploads, interact with other websites, deal with spam, and also protect your APIs using OAuth authentication whilst allowing people from all over the world to interact with your application.

    Zend Framework 2 Application Development is your guide to everything you need to know to build applications of any size for big and small companies alike, whilst using the right components for the job.

    Table of Contents

    1. Zend Framework 2 Application Development
      1. Table of Contents
      2. Zend Framework 2 Application Development
      3. Credits
      4. About the Author
      5. Acknowledgments
      6. About the Reviewers
      7. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      8. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      9. 1. Let's Build a Social Network
        1. Why ZF2?
        2. What are we going to build?
          1. Building a user profile
          2. Posting text
          3. Uploading pictures
          4. Sharing links
          5. Posting comments
          6. Building news reader
          7. Registering and logging in
          8. E-mails
          9. Public APIs
        3. The approach – API-centric app
        4. Summary
      10. 2. Setting Up the Environment
        1. Using the provided virtual machine
          1. Installing the required software
          2. Getting a copy of the files
          3. Vagrantfile
          4. VirtualBox subnet
          5. ZF2 skeleton
          6. Hosts file
          7. Vagrant commands
        2. Summary
      11. 3. Scratching the Surface of Zend Framework 2
        1. Bootstrap your app
          1. Configuration array
          2. PSR-0 and autoloaders
          3. ServiceManager
          4. EventManager
          5. ModuleManager
          6. Request object
          7. Response object
        2. The request object
        3. The router
          1. SimpleRouteStack
          2. TreeRouteStack
          3. Hostname
          4. Literal
          5. Method
          6. Part
          7. Regex
          8. Scheme
          9. Segment
          10. Wildcard
          11. Query
        4. DispatchListener
        5. Front controller
          1. InjectApplicationEvent
          2. ServiceLocatorAware
          3. EventManagerAware
          4. Controller plugins
          5. Controller types
            1. AbstractActionController
            2. AbstractRestfulController
        6. The response object
        7. An example is worth a thousand words
          1. The config folder
          2. Language files
          3. Module.php
          4. Src folder
          5. View folder
        8. Summary
      12. 4. The First Request/Response – Building the User Wall
        1. API development
          1. Requirements
          2. Working with the database
            1. Zend\Db\Adapter
            2. Zend\Db\TableGateway
            3. Zend\Db\RowGateway
            4. Setting up the connection
          3. ViewManager configuration
          4. Creating the Users module
            1. Creating the UsersTable.php file
            2. Module configuration
            3. The module.php file
          5. Adding the Wall module
            1. Module.php contents
            2. Module configuration
            3. Adding the IndexController.php file
          6. The API-Error approach
            1. Adding the Common module
            2. Modifying the application.config.php file
            3. Modifying the Module.php file
            4. Modifying the module.config.php file
            5. Adding the ApiErrorListener.php file
        2. Frontend
          1. Adding the Users module
            1. Contents of the Module.php file
            2. Creating the User.php file
          2. Requesting the wall content
            1. Modifying the Module.php file
            2. Module configuration
            3. Changes in the IndexController.php file
          3. Outputting the user wall
        3. Summary
      13. 5. Handling Text Content – Posting Text
        1. API development
          1. Requirements
          2. Working with the database
          3. Understanding the module structure
          4. Creating UserStatusesTable.php
          5. Extending IndexController.php
          6. Modifying module.config.php
        2. Frontend
          1. Creating Status.php
          2. Modifying User.php
          3. View
          4. TextStatusForm.php
          5. text-content-form.html
          6. Modifying IndexController.php
          7. Extending ApiClient.php
        3. Summary
      14. 6. Working with Images – Publishing Pictures
        1. API development
          1. Requirements
          2. Working with the database
          3. Changes on the module structure
          4. Creating the UserImagesTable.php file
          5. Extending the IndexController.php file
          6. Changing the module.config.php file
        2. Frontend
          1. Creating the Image.php file
          2. Adding the ImageForm.php file
          3. Showing the form in the image-content-form.phtml file
          4. Extending the User.php file
          5. Modifying the index.phtml file
          6. Modifying the IndexController.php file
          7. Modifying the layout.phtml file
        3. Summary
      15. 7. Dealing with URLs – Posting Links
        1. API development
          1. Requirements
          2. Working with the database
          3. Changes in the module structure
          4. Adding the UserLinksTable.php file
          5. Modifying the IndexController.php file
          6. Creating the Url.php file
          7. Modifying the module.config.php file
        2. Frontend
          1. Creating the link entity
          2. Adding the LinkForm.php file
          3. Creating the image-content-form.phtml file
          4. Extending the index.phtml file
          5. Changing the User.php file
          6. Modifying the IndexController.php file
        3. Summary
      16. 8. Dealing with Spam – Akismet to the Rescue
        1. API development
          1. Requirements
          2. Working with the database
          3. Module structure
          4. Installing Akismet service
          5. Modifying the local.php file
          6. Adding the UserCommentsTable.php file
          7. Creating the Spam.php file
          8. Extending the IndexController.php file
          9. Table gateways
        2. Frontend
          1. Adding the Comment.php file
          2. Adapting the Status.php file
          3. Modifying the Image.php and Link.php file
          4. Adding the CommentForm.php file
          5. Adding the comment-content-form.phtml file
          6. Modifying the IndexController.php file
          7. Extending the index.phtml file
        3. Summary
      17. 9. Let's Read Feeds – A News Reader
        1. Overview
        2. API development
          1. Requirements
          2. Working with the database
          3. Expanding the module structure
          4. The module.config.php file
          5. The Module.php file
          6. Adding the UserFeedsTable.php file
          7. Adding the UserFeedArticleTable.php file
          8. The contents of the IndexController.php file
          9. Creating the CliController.php file
          10. The ApiErrorListener.php file
        3. Frontend
          1. The API module
            1. Modifying the ApiClient.php file
          2. The Feeds module
            1. The contents of module.config.php
            2. The IndexController.php file
            3. Entities and forms
            4. The menu-feed-container.phtml file
            5. The index.phtml file
          3. The Common module
            1. The global.php file
            2. The layout.phtml file
        4. Summary
      18. 10. Sign Up
        1. Overview
        2. API development
          1. Requirements
          2. Working with the database
          3. The module structure
          4. Extending UsersTable.php
          5. The IndexController.php file
        3. Frontend
          1. The signup.phtml file
          2. The SignupForm.php file
          3. The signup-form.phtml file
          4. User.php
          5. The contents of the IndexController.php file
          6. The index.phtml file
          7. Changes in the ApiClient.php file
        4. Summary
      19. 11. Log in
        1. Overview
        2. API development
          1. Requirements
          2. Overview of the module structure
          3. The module.config.php file
          4. Creating the LoginController.php file
        3. Frontend
          1. The login form
          2. Changes in the ApiClient.php file
          3. Creating a new authentication adapter
          4. The IndexController.php file
          5. The login.phtml file
          6. Changes in module.config.php
          7. The global.php file
          8. The layout.phtml file
          9. ACLs
          10. Modules
          11. The index.phtml file
          12. Wall IndexController.php
        4. Summary
      20. 12. Sending E-mails
        1. Overview
        2. API development
          1. Requirements
          2. The module structure
          3. Adding the mailer.php file
          4. The email-layout.phtml file
          5. The view welcome.php file
          6. The view new-comment.phtml file
          7. Modifying the IndexController.php file
          8. The IndexController.php file on the Wall module
          9. The challenge
        3. Summary
      21. 13. OAuth 2.0 Protocol Securing our API
        1. Overview
        2. API development
          1. The module structure
          2. Installing the OAuth 2.0 component
          3. Modifying LoginController.php
          4. Adding OAuthListener.php to the Common module
          5. Other changes in the Common module
        3. Frontend
          1. Modifying ApiClient.php
          2. Modifying Api.php
        4. Following the OAuth 2.0 flow
        5. The challenge
        6. Summary
      22. Index