Zend Framework 2 Application Development


Zend Framework 2 Application Development
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
$22.94
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
$44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters

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

Book Details

Language : English
Paperback : 298 pages [ 235mm x 191mm ]
Release Date : October 2013
ISBN : 1782162100
ISBN 13 : 9781782162100
Author(s) : Christopher Valles
Topics and Technologies : All Books, Web Development, Open Source, PHP

Table of Contents

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

                            Christopher Valles

                            Christopher Valles is a Software Engineer from Barcelona, Spain, currently based in London, UK. He started developing when he was seven using a Vtech kid laptop that was strangely shipped with a simple version of the BASIC programming language. Since then, he has explored more than 16 different programming languages ranging from Assembler to PHP, Python, and GO. Chris also stepped into the sysadmin role and has been managing systems since he started working in this industry. He has taken care of servers right from simple webservers to infrastructures on the Cloud and internal Mac infrastructures. He is an Apple Certified Support Professional and Apple Certified Technical Coordinator. His desire to learn and experiment has driven him to explore other fields, such as machine learning and robotics. He currently owns close to five robots and has built more than 20 over the past years. If you don't find him on the computer, he is probably spending time in the kitchen cooking delicious recipes. The sectors where Chris has worked ranges from adult content websites and payment processors to social networks and the gaming industry. Presently, he's working as a Software Engineer at Hailo Networks, Ltd.
                            Sorry, we don't have any reviews for this title yet.

                            Code Downloads

                            Download the code and support files for this book.


                            Submit Errata

                            Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                            Errata

                            - 12 submitted: last submission 17 Apr 2014

                            Errata type: Code related Page no: 264    It is: useZend\Session\Container;   It should be: use Zend\Session\Container;

                            Errata type: Typo related Pg no: 83 It is: use Zend\Mvc\Controller\AbstractActionController; use Zend\Stdlib\Hydrator\ClassMethods; use Wall\Entity\User; use Api\Client\ApiClient as ApiClient; It should be: use Wall\Entity\User; use Api\Client\ApiClient as ApiClient;

                            Errata type: Code related Page no: 76It is: 'Common\Listeners\ApiProblemListener' =>        'Common\Listeners\ApiProblemListener',It should be: 'Common\Listeners\ApiErrorListener' =>               'Common\Listeners\ApiErrrorListener',

                            Errata type: Code related Page no: 77It is: $model = new JsonModel(array(       'errorCode' => $exception->getCode() ?: $httpCode,       'errorMsg' => $exception->getMessage()       ));It should be: $model = new JsonModel(array(              'errorCode' => !empty($exception) ? $exception->getCode() : $httpCode,              'errorMsg' => !empty($exception) ? $exception->getMessage() : NULL              ));

                            Errata type: Code related Page no: 76It is: class ApiErrorListener implements AbstractListenerAggregateIt should be: class ApiErrorListener extends AbstractListenerAggregate

                            Errata type: Code related Page no: 72 It is: $this->usersTable = $sm->get(Users\Model\UsersTable'); It should be: $this->usersTable = $sm->get('Users\Model\UsersTable');

                            Errata type: Typo  Page no: 115 It is: Of course, the first thing we should do is change the name of the class; in this case the class will be called UserImagesTable. It should be: Of course, the first thing we should do is to change the name of the class; in this case the class will be called UserImagesTable.

                            Errata type: Technical Page no: 191 It is: After looping through all the articles, we print more debug information and then update the timestamp for this feed on the database, fi nishing with more debug strings.It should be: If verbose parameter was set, after loopingthrough all the articles, we print more debug information. Thenupdate the timestamp for this feed on the database, finishing with moredebug strings (in verbose mode).

                            Errata Type: Graphics | Page no: 101

                             

                            The folder structure image is incorrect. The Status.php file is actually in the User module and not in the Wall module.

                            Errata Type: Code Related | Page no: 185


                            foreach ($feedsFromDb as $f) {
                            $feeds[$f->id] = $f;
                            $feeds[$f->id]]['articles'] = $userFeedArticlesTable
                            ->getByFeedId($f->id)->toArray();
                            }

                            Should be:

                            foreach ($feedsFromDb as $f) {
                            $feeds[$f->id] = $f;
                            $feeds[$f->id]['articles'] = $userFeedArticlesTable
                            ->getByFeedId($f->id)->toArray();
                            }

                            Errata Type: Code Related | Page no: 119


                            One line of code should be omitted in the createImage method.

                            At the bottom of page 119, the line "$filters->isValid();" should not be there.

                            Errata Type: Code Related | Page no: 157


                            On line 3 of the page:

                            )->order('created_at ASC);

                            Should be:

                            )->order('created_at ASC');

                            Sample chapters

                            You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                            Frequently bought together

                            Zend Framework 2 Application Development +    Zend Framework 2.0 by Example: Beginner’s Guide =
                            50% Off
                            the second eBook
                            Price for both: £24.65

                            Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                            What you will learn from this book

                            Get to grips with the features of Zend Framework 2’s MVC architecture Filter and validate data no matter what the content is Handle and manage file uploads Gather content from other websites Fight spam with services such as Akismet Pull content from RSS feeds Quickly build forms such as login, register, and so on. Protect your API layer by using authentication protocols such as OAuth Manage database operations Build web services using the latest controller types

                            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.

                            Approach

                            Every concept is put into practice with clear, step-by-step instructions and a hands-on approach. Forget about hundreds of pages full of theory; learn everything by example with Zend Framework 2 Application Development.

                            Who this book is for

                            Written for PHP developers who want to get started with Zend Framework 2. Whether you are learning Zend framework from scratch or looking to sharpen up your skills from previous versions, Zend Framework 2 Application Development will help you to harness the power of Zend to produce better and more powerful applications. Basic knowledge of object-oriented design will be helpful.

                            Code Download and Errata
                            Packt Anytime, Anywhere
                            Register Books
                            Print Upgrades
                            eBook Downloads
                            Video Support
                            Contact Us
                            Awards Voting Nominations Previous Winners
                            Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                            Resources
                            Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software