zend framework advanced training
DESCRIPTION
ZEND FRAMEWORK Advanced Training. By: Raza Mehdi. Topics Covered in Previous Session. What is Zend Framework? What is Model-View-Controller Pattern? Coding Guidelines for Zend Framework. Difference between Zend Framework versions. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/1.jpg)
ZEND FRAMEWORK Advanced Training
http://kb.vteamslabs.com 1
By: Raza Mehdi
![Page 2: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/2.jpg)
Topics Covered in Previous Session• What is Zend Framework?• What is Model-View-Controller Pattern?• Coding Guidelines for Zend Framework.• Difference between Zend Framework versions.• Development of a simple Application using Zend Framework
to showcase its various features.
2http://kb.vteamslabs.com
![Page 3: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/3.jpg)
TOPICS FOR SESSION
• Themes using Zend_Layout & Zend_View• Zend_Pagination• Managing Table Relationships using Zend_Db• Handling Security in Zend Framework.• Site Search Using Zend_Search_Lucene.• Modules in Zend Framework.
http://kb.vteamslabs.com 3
![Page 4: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/4.jpg)
THEMES Using Zend_Layout & Zend_View
http://kb.vteamslabs.com 4
![Page 5: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/5.jpg)
1. Layout & Views Folders
http://kb.vteamslabs.com 5
![Page 6: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/6.jpg)
2. Changed Layout & Views Folders for Themes
http://kb.vteamslabs.com 6
![Page 7: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/7.jpg)
3. Change Bootstrap.php to load Themes
http://kb.vteamslabs.com 7
• Add a constructor function to load theme of choice:
![Page 8: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/8.jpg)
3. Change Bootstrap.php to load Themes (cont ..)
http://kb.vteamslabs.com 8
• Add a _initLayout function to load layout files of selected theme:
![Page 9: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/9.jpg)
3. Change Bootstrap.php to load Themes (cont ..)
http://kb.vteamslabs.com 9
• Add a _initView function to load view files of selected theme:
![Page 10: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/10.jpg)
4. Create Theme Configuration File
http://kb.vteamslabs.com 10
• The template.xml in each theme folder may hold theme config information as well as theme’s CSS & JS filenames. For example:
![Page 11: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/11.jpg)
5. Create View Helper To Load Theme Config
Create a file called LoadTemplate.php in application/views/helpers folder to load
information from template.xml.
http://kb.vteamslabs.com 11
![Page 12: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/12.jpg)
5.1 Loading Theme Config Data
http://kb.vteamslabs.com 12
![Page 13: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/13.jpg)
5.2 Saving Configuration Data
http://kb.vteamslabs.com 13
• Next we will save the retrieved configuration data as array.
![Page 14: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/14.jpg)
5.3 Adding Configuration Data To Layout
http://kb.vteamslabs.com 14
• Finally we will add the items to the Layout.
![Page 15: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/15.jpg)
http://kb.vteamslabs.com 15
![Page 16: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/16.jpg)
6. Update Layout Files
http://kb.vteamslabs.com 16
![Page 17: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/17.jpg)
USING Zend_Paginator to paginate records
http://kb.vteamslabs.com 17
![Page 18: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/18.jpg)
1. Update Model’s method to return Zend_Paginator object
http://kb.vteamslabs.com 18
![Page 19: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/19.jpg)
2. Update Controller’s method which lists records
http://kb.vteamslabs.com 19
![Page 20: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/20.jpg)
3. Update View File
http://kb.vteamslabs.com 20
![Page 21: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/21.jpg)
4. Creating Paginator Template
http://kb.vteamslabs.com 21
• Create a new folder named partials in application/views/scripts.
• Now create a file pagination-control.phtml.• Put in the following code in the file
![Page 22: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/22.jpg)
4.1 Adding Request Parameters to URL
http://kb.vteamslabs.com 22
![Page 23: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/23.jpg)
4.2 Adding Previous Page Control to Paginator
http://kb.vteamslabs.com 23
![Page 24: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/24.jpg)
4.3 Adding Total Pages List to Paginator
http://kb.vteamslabs.com 24
![Page 25: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/25.jpg)
4.4 Adding Next Page Control to Paginator
http://kb.vteamslabs.com 25
![Page 26: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/26.jpg)
http://kb.vteamslabs.com 26
![Page 27: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/27.jpg)
http://kb.vteamslabs.com 27
![Page 28: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/28.jpg)
Managing table relationships using Zend_Db
http://kb.vteamslabs.com 28
![Page 29: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/29.jpg)
1. Defining Relationship Between Database Tables• In this case, we will take example of a simple CMS.
– Have two tables page & node.– A page can have multiple nodes. – A Page can be parent to another page.
http://kb.vteamslabs.com 29
![Page 30: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/30.jpg)
2. Creating Models for Tables
http://kb.vteamslabs.com 30
![Page 31: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/31.jpg)
3. Defining Relationships for Models
http://kb.vteamslabs.com 31
• Since pages table has a One-to-many Relationship with the content_nodes table, we need to do the following:
– Model_Page: Tell Zend_Db_Table that the pages table is dependent on the content_nodes table.
– Model_ContentNode: Tell Zend_Db_Table that the content_nodes table is related to the pages table, by doing the following:• Setting the related columns. • Adding reference table class (Model_Page). • Setting the referenced table columns.
![Page 32: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/32.jpg)
4. ContentNode to Page Relationship
http://kb.vteamslabs.com 32
• Add the following code to the application/models/ContentNode.php:
![Page 33: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/33.jpg)
5. Page to Page Relationship
http://kb.vteamslabs.com 33
• Add the following code to the application/models/Page.php:
![Page 34: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/34.jpg)
6. Fetching Dependent Rows
http://kb.vteamslabs.com 34
![Page 35: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/35.jpg)
7. Fetching Parent Rows
http://kb.vteamslabs.com 35
![Page 36: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/36.jpg)
HANDLING SECURITY IN ZEND FRAMEWORK
http://kb.vteamslabs.com 36
![Page 37: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/37.jpg)
• Security in Zend Framework is done through:– Zend_Auth solely concerned with authenticating
(and persisting) the application users.
– Zend_Acl handles resources, roles (user roles), and which roles can access which resources.
http://kb.vteamslabs.com 37
![Page 38: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/38.jpg)
1. Managing Users• Normally we have two user types in a CMS:
– Users: These are registered users who don’t have admin privileges.
– Administrators: These are the site managers who can access any area of the CMS.
Fields for Users Table:• `id`• `username`• `password`• `first_name` • `last_name` • `role`
http://kb.vteamslabs.com 38
![Page 39: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/39.jpg)
2. Creating User Model Class
http://kb.vteamslabs.com 39
![Page 40: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/40.jpg)
User Authentication using Zend_Auth
http://kb.vteamslabs.com 40
![Page 41: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/41.jpg)
LIST OF AVAILABLE ZEND_AUTH ADAPTERS• Some of the common Zend_Auth adapters are:
– Database table authentication.– Digest authentication.– LDAP authentication.– Open ID.
Here, we will use Zend_Auth_Adapter_DbTable.
http://kb.vteamslabs.com 41
![Page 42: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/42.jpg)
SAMPLE USAGE OF Zend_Auth
http://kb.vteamslabs.com 42
![Page 43: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/43.jpg)
CREATING THE USER LOGIN
http://kb.vteamslabs.com 43
![Page 44: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/44.jpg)
1. Adding the Login Form to Controller
http://kb.vteamslabs.com 44
![Page 45: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/45.jpg)
2. Adding the Login Form to View
http://kb.vteamslabs.com 45
![Page 46: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/46.jpg)
3. Adding User Authentication
First validate the form. If valid, then get the posted data:
http://kb.vteamslabs.com 46
![Page 47: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/47.jpg)
3. Adding User Authentication (continued …)
• Creating Zend_Auth Adapter.• Pass the username & password.• Do the authentication.
http://kb.vteamslabs.com 47
![Page 48: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/48.jpg)
3. Adding User Authentication (continued …)
• Get the Zend_Auth authentication data.– Store the valid Zend_Auth data in storage (PHP session).
Then redirect the user to some page.– Show error message in case of invalid result.
http://kb.vteamslabs.com 48
![Page 49: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/49.jpg)
http://kb.vteamslabs.com 49
![Page 50: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/50.jpg)
LOGOUT FOR AUTHENTICATED USERS
http://kb.vteamslabs.com 50
![Page 51: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/51.jpg)
http://kb.vteamslabs.com 51
![Page 52: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/52.jpg)
Controlling Access using Zend_Acl
http://kb.vteamslabs.com 52
![Page 53: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/53.jpg)
SAMPLE USAGE OF Zend_Acl
http://kb.vteamslabs.com 53
![Page 54: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/54.jpg)
SECURING RESOURCES USING ZEND_ACL
http://kb.vteamslabs.com 54
![Page 55: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/55.jpg)
1. Creating a Controller Plugin• Create a folder CMS in application/library.• Create a folder Controller in CMS folder.• Create another folder Plugin in the Controller folder.• Create a file Acl.php in the Plugin folder.
http://kb.vteamslabs.com 55
![Page 56: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/56.jpg)
2. Creating ACL Instance, roles & resourcesCreating a Zend_Acl instance, and then adding relevant roles & resources:
http://kb.vteamslabs.com 56
![Page 57: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/57.jpg)
3. Access Rules for Roles & Resources
http://kb.vteamslabs.com 57
![Page 58: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/58.jpg)
4. Authenticating User Requests
http://kb.vteamslabs.com 58
![Page 59: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/59.jpg)
http://kb.vteamslabs.com 59
![Page 60: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/60.jpg)
5. Registering Plugin for Controller
Open the application/configs/application.ini, and add the following lines:
resources.frontController.plugins.acl = "CMS_Controller_Plugin_Acl"
http://kb.vteamslabs.com 60
![Page 61: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/61.jpg)
6. Adding Unauthorized Access Landing Page• Add the noauth action to the
application/controller/ErrorController.php file, and the add the following code to its relevant view file:
http://kb.vteamslabs.com 61
![Page 62: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/62.jpg)
Site Search using Zend_Search_Lucene
http://kb.vteamslabs.com 62
![Page 63: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/63.jpg)
What Is Zend_Search_Lucene?• Zend_Search_Lucene provides a very straightforward
way to build and search indexes of content. Through this, you can do the following:
– Create Search Indexes.– Add Documents for searching content.– Create fields to add to documents for search.
http://kb.vteamslabs.com 63
![Page 64: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/64.jpg)
IMPLEMENTING SEARCH
http://kb.vteamslabs.com 64
![Page 65: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/65.jpg)
1. Adding the Search Controller
• Create a file SearchController.php in the applications/controllers file.
• Add the following methods to the file, and create the relevant view files in the application/views/scripts/search folder:– indexAction()– buildAction()– searchAction()
http://kb.vteamslabs.com 65
![Page 66: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/66.jpg)
2. Securing the Search Functionality
• Add the following code to Acl.php in the application/library/CMS/Controller/Plugin folder:
http://kb.vteamslabs.com 66
![Page 67: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/67.jpg)
3. Create the folder to store search indexes
Create a folder indexes in the application folder
http://kb.vteamslabs.com 67
![Page 68: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/68.jpg)
4. BUILDING THE SEARCH INDEX
http://kb.vteamslabs.com 68
![Page 69: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/69.jpg)
4.1 Create search index & fetch all records
Add the following code to buildAction method for SearchController.php file.
http://kb.vteamslabs.com 69
![Page 70: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/70.jpg)
4.2 Create search document for every record
http://kb.vteamslabs.com 70
![Page 71: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/71.jpg)
4.3 Optimizing the index & displaying indexing results
http://kb.vteamslabs.com 71
![Page 72: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/72.jpg)
4.4 Updating Search index view file
http://kb.vteamslabs.com 72
![Page 73: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/73.jpg)
5. SEARCHING THE SITE
http://kb.vteamslabs.com 73
![Page 74: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/74.jpg)
5.1 Creating the Search Form Create a file Search.php in the application/forms folder:
http://kb.vteamslabs.com 74
![Page 75: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/75.jpg)
5.2 Adding Search Form to LayoutAdding the following code to layout.phtml file in the application/layouts/scripts folder:
http://kb.vteamslabs.com 75
![Page 76: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/76.jpg)
5.3 Processing a Search Request
http://kb.vteamslabs.com 76
![Page 77: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/77.jpg)
5.3 Rendering Search Results
http://kb.vteamslabs.com 77
![Page 78: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/78.jpg)
ADDING MODULES IN ZEND FRAMEWORK APPLICATION
http://kb.vteamslabs.com 78
![Page 79: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/79.jpg)
1. Creating Modules• Create a new folder in the application folder named
modules.• Create a module folder name of your choice e.g.
contact.• Create subfolders in the your module folder in this
order:– application/modules/contact/controllers– application/modules/contact/models– application/modules/contact/views
• application/modules/contact/views/scripts• application/modules/contact/views/helpers
. http://kb.vteamslabs.com 79
![Page 80: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/80.jpg)
Run this command:zf create module contact
in the terminal or command prompt in the project directory
http://kb.vteamslabs.com 80
![Page 81: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/81.jpg)
Creating Resources in Modules
• Any custom functionality must be done in the modules’s Bootstrap.php file. This must be done with care.
• For every resource you need to add prefix [module_name] to class definition. For example:
– For Controller: [module_name]_IndexController.php– For Model: [module_name]_Model_Page.php– For Form: [module_name]_Form_User.php
http://kb.vteamslabs.com 81
![Page 82: ZEND FRAMEWORK Advanced Training](https://reader036.vdocuments.mx/reader036/viewer/2022081420/568160b0550346895dcfd25d/html5/thumbnails/82.jpg)
Thank You
QUESTIONS
http://kb.vteamslabs.com 82