Zend Framework Is As Follows
Total Page:16
File Type:pdf, Size:1020Kb
Zend Framework i Zend Framework About the Tutorial Zend is an open source PHP framework. It is pure object-oriented and built around the MVC design pattern. Zend framework contains collection of PHP packages which can be used to develop web applications and services. Zend was started by Andi Gutmans and Zeev Suraski. This tutorial will give you a quick introduction to Zend Framework and make you comfortable with its various components. Audience This tutorial has been prepared for professionals who are aspiring to make a career in Zend framework. This will give you enough understanding on how to create and develop a website using Zend. Prerequisites Before proceeding with the various types of components given in this tutorial, it is being assumed that the readers are already aware about what a Framework is. In addition to this, it will also be very helpful if you have sound knowledge on HTML, PHP and the OOPS concepts. Copyright & Disclaimer Copyright 2017 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at [email protected] i Zend Framework Table of Contents About the Tutorial .................................................................................................................................... i Audience .................................................................................................................................................. i Prerequisites ............................................................................................................................................ i Copyright & Disclaimer ............................................................................................................................. i Table of Contents .................................................................................................................................... ii 1. ZEND FRAMEWORK – INTRODUCTION ................................................................................ 1 2. ZEND FRAMEWORK – INSTALLATION................................................................................... 3 Install Zend Framework ........................................................................................................................... 3 3. ZEND FRAMEWORK – SKELETON APPLICATION ................................................................... 4 Installation using Composer .................................................................................................................... 4 Unit Tests ................................................................................................................................................ 8 Apache Web Server ............................................................................................................................... 11 4. ZEND FRAMEWORK – MVC ARCHITECTURE ....................................................................... 12 5. ZEND FRAMEWORK – CONCEPTS ...................................................................................... 13 6. ZEND FRAMEWORK – SERVICE MANAGER ......................................................................... 14 Install Service Manager ......................................................................................................................... 14 Factory Method..................................................................................................................................... 15 Abstract Factory Method ...................................................................................................................... 17 Initializer Method.................................................................................................................................. 17 Delegator Factory Method .................................................................................................................... 18 Plugin Manager ..................................................................................................................................... 18 Configuration Option ............................................................................................................................ 19 ii Zend Framework 7. ZEND FRAMEWORK – EVENT MANAGER ........................................................................... 20 8. ZEND FRAMEWORK – MODULE SYSTEM ............................................................................ 25 MVC Web Module System ..................................................................................................................... 25 Module Class ......................................................................................................................................... 26 9. ZEND FRAMEWORK – APPLICATION STRUCTURE ............................................................... 27 Structure of the Application Modules ................................................................................................... 31 10. ZEND FRAMEWORK – CREATING A MODULE ..................................................................... 33 11. ZEND FRAMEWORK – CONTROLLERS................................................................................. 37 AbstractActionController ...................................................................................................................... 38 AbstractRestfulController...................................................................................................................... 39 AbstractConsoleController .................................................................................................................... 39 12. ZEND FRAMEWORK – ROUTING ........................................................................................ 40 Route & RouteStack .............................................................................................................................. 40 Type of Routes ...................................................................................................................................... 41 Configuring Route in Tutorial Module ................................................................................................... 43 13. ZEND FRAMEWORK – VIEW LAYER .................................................................................... 45 View Layer Configuration ...................................................................................................................... 45 Controllers and View Layer ................................................................................................................... 46 Passing Data to View Layer ................................................................................................................... 47 View Helpers ......................................................................................................................................... 47 Built-in Helpers ..................................................................................................................................... 48 Creating View Helpers ........................................................................................................................... 56 iii Zend Framework 14. ZEND FRAMEWORK – LAYOUT ........................................................................................... 58 Creating a new layout ........................................................................................................................... 60 15. ZEND FRAMEWORK – MODELS & DATABASE ..................................................................... 62 Models in Zend Framework ................................................................................................................... 62 Database in Zend Framework ................................................................................................................ 62 16. ZEND FRAMEWORK – DIFFERENT DATABASES ................................................................... 70 17. ZEND FRAMEWORK – FORMS & VALIDATION .................................................................... 72 Install Form Component ........................................................................................................................ 72 Example ................................................................................................................................................ 72 18. ZEND FRAMEWORK – FILE UPLOADING ............................................................................. 81 FileInput Class ....................................................................................................................................... 81 File Upload – Working Example ............................................................................................................. 82 19. ZEND FRAMEWORK – AJAX ...............................................................................................