SlideShare a Scribd company logo
John Coggeshall
Hi! I’m John! 
• Involved in PHP since circa 1996 
• Sr. Architect, Zend Global Services 
• PHP Core Contributor 
• ZF Contributor
Getting Started 
 The easiest way to get started in ZF2 is to 
start with the skeleton application: 
https://github.com/zendframework/zendskeletonapplication 
$ composer create-project  
-sdev  
-repository-url=“https://packages.zendframework.com”  
zendframework/skeleton-application  
/path/to/install
ZF2 Modules 
 In ZF2 modules are a core concept when 
developing applications. Everything including 
the application is a module. 
 Modules can be application-specific or can be 
written generically and then loaded into the 
application via composer
How are modules structured?
How do Modules work? 
 Every ZF2 module starts with a Module class 
which describes the module and the things it 
provides to the application 
 Services 
 Event Handlers 
 Controllers 
 Routes 
 Etc.
How do Modules work? 
 Modules also have their own configuration 
files which can setup default values that are 
later over-written by the application’s 
configurations. 
 Useful for creating module-specific routes, or 
module-specific configurations, etc. 
 config/module.config.php
How do Modules work? 
 The module class can implement a number of 
useful methods 
 getAutoLoaderConfig() – configure the way 
classes are autoloaded through this module 
 getServiceConfig() – set up the way services this 
module provides can be created and accessed 
 getModuleDependencies() – Define module 
dependencies 
 onBootstrap() – Executed when module is fired up
Service Manager 
 ZF2 applications in general rely heavily on 
something called the Service Manager to deal 
with application dependencies 
 Examples: The DB adapter used by the 
application is created by the Service Manager
Service Manager 
 Implementing dependencies and 
components as services allows modules to be 
completely decoupled from each other 
 Services are identified by unique ID, which is 
referenced when the service is required 
 Customization (i.e. a different DB adapter) 
can be done simply by over-writing the 
factory associated with that unique ID
Service Manager 
 In a module services can be defined in various 
locations 
 module.config.php (the ‘service_manager’ key) 
 Module::getServiceConfig() (the programatic 
approach)
Service Manager 
 How services can be defined 
 By factory – identify the key to either a class that 
implements a Factory interface or other callable 
which returns the instance 
 By invokable – Simply identify the class associated 
with this service 
 Aliases – Services can have an alias for 
complicated dependency scenarios
Using Events 
 All events are managed through the event 
manager class(es) 
 Can be automatically injected into your objects via 
the Service Locator 
 Implement the EventManagerAwareInterface
Event Managers 
 The ZF2 Event manager is the primary way 
modules should communicate with each 
other 
 Optionally, also internally 
 Broadcast Events for others to react to 
 I.e. “Dispatch”
ZF2 Baked in Events 
 ZF2 uses events throughout its core functionality 
 Module Manager 
 Application 
 Bootstrap, etc. 
 MVC Events 
 Routing 
 Dispatching 
 Rendering 
 http://akrabat.com/zend-framework-2/a-list-of-zf2- 
events/
Event Scoping 
 Events are by default scoped to the local 
object 
 Each Event Manger is by default unique to that 
object 
 If you want to have events of a different 
scope you have a few options 
 Provide a way to get your event manager 
 Use the more global SharedEventManager
Summary 
 This is a very surface-level exploration into 
the complex possibilities of ZF2 modules and 
events, but enough to get started. 
 Get to know Service Manager and Event 
Manager very well and they will serve you 
fantastically, allowing you to write powerful 
reusable components
Any questions? 
Tell me what you think: http://joind.in/11875 
Slides will be available at http://www.slideshare.net/coogle

More Related Content

Similar to ZF2 Modules: Events, Services, and of course, modularity

Zend con practical-zf1-zf2-migration
Zend con practical-zf1-zf2-migrationZend con practical-zf1-zf2-migration
Zend con practical-zf1-zf2-migration
Clark Everetts
 
Николай Паламарчук "Управление зависимостями в больших проектах"
Николай Паламарчук "Управление зависимостями в больших проектах" Николай Паламарчук "Управление зависимостями в больших проектах"
Николай Паламарчук "Управление зависимостями в больших проектах"
Fwdays
 
JavaScript Module Loaders
JavaScript Module LoadersJavaScript Module Loaders
JavaScript Module Loaders
zeroproductionincidents
 
ZF2 Modular Architecture - Taking advantage of it
ZF2 Modular Architecture - Taking advantage of itZF2 Modular Architecture - Taking advantage of it
ZF2 Modular Architecture - Taking advantage of it
Steve Maraspin
 
Soft serve prism
Soft serve prismSoft serve prism
Soft serve prism
dotNETUserGroupDnipro
 
Ростислав Михайлив "Zend Framework 3 - evolution or revolution"
Ростислав Михайлив "Zend Framework 3 - evolution or revolution"Ростислав Михайлив "Zend Framework 3 - evolution or revolution"
Ростислав Михайлив "Zend Framework 3 - evolution or revolution"
Fwdays
 
Composite Application Library, Prism v2
Composite Application Library, Prism v2Composite Application Library, Prism v2
Composite Application Library, Prism v2
Orbit One - We create coherence
 
ZF2: Writing Service Components
ZF2: Writing Service ComponentsZF2: Writing Service Components
ZF2: Writing Service Components
Mike Willbanks
 
Model-driven Distributed Software Deployment
Model-driven Distributed Software DeploymentModel-driven Distributed Software Deployment
Model-driven Distributed Software Deployment
Sander van der Burg
 
SeedStack feature tour
SeedStack feature tourSeedStack feature tour
SeedStack feature tour
SeedStack
 
Getting modular with OSGI
Getting modular with OSGIGetting modular with OSGI
Getting modular with OSGI
Andrii Krokhmalnyi
 
Spring boot
Spring bootSpring boot
MuleSoft Surat Live Demonstration Virtual Meetup#3 - Building JWT OAuth 2.0 C...
MuleSoft Surat Live Demonstration Virtual Meetup#3 - Building JWT OAuth 2.0 C...MuleSoft Surat Live Demonstration Virtual Meetup#3 - Building JWT OAuth 2.0 C...
MuleSoft Surat Live Demonstration Virtual Meetup#3 - Building JWT OAuth 2.0 C...
Jitendra Bafna
 
Spring 2
Spring 2Spring 2
Spring 2
Aruvi Thottlan
 
Facade Design Pattern
Facade Design PatternFacade Design Pattern
Facade Design Pattern
S. M. Masoud Sadrnezhaad
 
Node Session - 2
Node Session - 2Node Session - 2
Node Session - 2
Bhavin Shah
 
Meteor
MeteorMeteor
Nt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language AnalysisNt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language Analysis
Nicole Gomez
 
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
Dave Bost
 
NodeJs Modules1.pdf
NodeJs Modules1.pdfNodeJs Modules1.pdf
NodeJs Modules1.pdf
Bareen Shaikh
 

Similar to ZF2 Modules: Events, Services, and of course, modularity (20)

Zend con practical-zf1-zf2-migration
Zend con practical-zf1-zf2-migrationZend con practical-zf1-zf2-migration
Zend con practical-zf1-zf2-migration
 
Николай Паламарчук "Управление зависимостями в больших проектах"
Николай Паламарчук "Управление зависимостями в больших проектах" Николай Паламарчук "Управление зависимостями в больших проектах"
Николай Паламарчук "Управление зависимостями в больших проектах"
 
JavaScript Module Loaders
JavaScript Module LoadersJavaScript Module Loaders
JavaScript Module Loaders
 
ZF2 Modular Architecture - Taking advantage of it
ZF2 Modular Architecture - Taking advantage of itZF2 Modular Architecture - Taking advantage of it
ZF2 Modular Architecture - Taking advantage of it
 
Soft serve prism
Soft serve prismSoft serve prism
Soft serve prism
 
Ростислав Михайлив "Zend Framework 3 - evolution or revolution"
Ростислав Михайлив "Zend Framework 3 - evolution or revolution"Ростислав Михайлив "Zend Framework 3 - evolution or revolution"
Ростислав Михайлив "Zend Framework 3 - evolution or revolution"
 
Composite Application Library, Prism v2
Composite Application Library, Prism v2Composite Application Library, Prism v2
Composite Application Library, Prism v2
 
ZF2: Writing Service Components
ZF2: Writing Service ComponentsZF2: Writing Service Components
ZF2: Writing Service Components
 
Model-driven Distributed Software Deployment
Model-driven Distributed Software DeploymentModel-driven Distributed Software Deployment
Model-driven Distributed Software Deployment
 
SeedStack feature tour
SeedStack feature tourSeedStack feature tour
SeedStack feature tour
 
Getting modular with OSGI
Getting modular with OSGIGetting modular with OSGI
Getting modular with OSGI
 
Spring boot
Spring bootSpring boot
Spring boot
 
MuleSoft Surat Live Demonstration Virtual Meetup#3 - Building JWT OAuth 2.0 C...
MuleSoft Surat Live Demonstration Virtual Meetup#3 - Building JWT OAuth 2.0 C...MuleSoft Surat Live Demonstration Virtual Meetup#3 - Building JWT OAuth 2.0 C...
MuleSoft Surat Live Demonstration Virtual Meetup#3 - Building JWT OAuth 2.0 C...
 
Spring 2
Spring 2Spring 2
Spring 2
 
Facade Design Pattern
Facade Design PatternFacade Design Pattern
Facade Design Pattern
 
Node Session - 2
Node Session - 2Node Session - 2
Node Session - 2
 
Meteor
MeteorMeteor
Meteor
 
Nt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language AnalysisNt1310 Unit 3 Language Analysis
Nt1310 Unit 3 Language Analysis
 
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
 
NodeJs Modules1.pdf
NodeJs Modules1.pdfNodeJs Modules1.pdf
NodeJs Modules1.pdf
 

More from John Coggeshall

Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
John Coggeshall
 
Migrating to PHP 7
Migrating to PHP 7Migrating to PHP 7
Migrating to PHP 7
John Coggeshall
 
Peek at PHP 7
Peek at PHP 7Peek at PHP 7
Peek at PHP 7
John Coggeshall
 
PHP Development for Google Glass using Phass
PHP Development for Google Glass using PhassPHP Development for Google Glass using Phass
PHP Development for Google Glass using Phass
John Coggeshall
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
John Coggeshall
 
Development with Vagrant
Development with VagrantDevelopment with Vagrant
Development with Vagrant
John Coggeshall
 
10 things not to do at a Startup
10 things not to do at a Startup10 things not to do at a Startup
10 things not to do at a Startup
John Coggeshall
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
John Coggeshall
 
Puppet
PuppetPuppet
Building PHP Powered Android Applications
Building PHP Powered Android ApplicationsBuilding PHP Powered Android Applications
Building PHP Powered Android Applications
John Coggeshall
 
Ria Applications And PHP
Ria Applications And PHPRia Applications And PHP
Ria Applications And PHP
John Coggeshall
 
Beyond the Browser
Beyond the BrowserBeyond the Browser
Beyond the Browser
John Coggeshall
 
Apache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 MistakesApache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 Mistakes
John Coggeshall
 
Ria Development With Flex And PHP
Ria Development With Flex And PHPRia Development With Flex And PHP
Ria Development With Flex And PHP
John Coggeshall
 
Top 10 Scalability Mistakes
Top 10 Scalability MistakesTop 10 Scalability Mistakes
Top 10 Scalability Mistakes
John Coggeshall
 
Enterprise PHP: A Case Study
Enterprise PHP: A Case StudyEnterprise PHP: A Case Study
Enterprise PHP: A Case Study
John Coggeshall
 
Building Dynamic Web Applications on i5 with PHP
Building Dynamic Web Applications on i5 with PHPBuilding Dynamic Web Applications on i5 with PHP
Building Dynamic Web Applications on i5 with PHP
John Coggeshall
 
PHP Security Basics
PHP Security BasicsPHP Security Basics
PHP Security Basics
John Coggeshall
 
Migrating from PHP 4 to PHP 5
Migrating from PHP 4 to PHP 5Migrating from PHP 4 to PHP 5
Migrating from PHP 4 to PHP 5
John Coggeshall
 
Ajax and PHP
Ajax and PHPAjax and PHP
Ajax and PHP
John Coggeshall
 

More from John Coggeshall (20)

Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
 
Migrating to PHP 7
Migrating to PHP 7Migrating to PHP 7
Migrating to PHP 7
 
Peek at PHP 7
Peek at PHP 7Peek at PHP 7
Peek at PHP 7
 
PHP Development for Google Glass using Phass
PHP Development for Google Glass using PhassPHP Development for Google Glass using Phass
PHP Development for Google Glass using Phass
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
 
Development with Vagrant
Development with VagrantDevelopment with Vagrant
Development with Vagrant
 
10 things not to do at a Startup
10 things not to do at a Startup10 things not to do at a Startup
10 things not to do at a Startup
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
 
Puppet
PuppetPuppet
Puppet
 
Building PHP Powered Android Applications
Building PHP Powered Android ApplicationsBuilding PHP Powered Android Applications
Building PHP Powered Android Applications
 
Ria Applications And PHP
Ria Applications And PHPRia Applications And PHP
Ria Applications And PHP
 
Beyond the Browser
Beyond the BrowserBeyond the Browser
Beyond the Browser
 
Apache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 MistakesApache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 Mistakes
 
Ria Development With Flex And PHP
Ria Development With Flex And PHPRia Development With Flex And PHP
Ria Development With Flex And PHP
 
Top 10 Scalability Mistakes
Top 10 Scalability MistakesTop 10 Scalability Mistakes
Top 10 Scalability Mistakes
 
Enterprise PHP: A Case Study
Enterprise PHP: A Case StudyEnterprise PHP: A Case Study
Enterprise PHP: A Case Study
 
Building Dynamic Web Applications on i5 with PHP
Building Dynamic Web Applications on i5 with PHPBuilding Dynamic Web Applications on i5 with PHP
Building Dynamic Web Applications on i5 with PHP
 
PHP Security Basics
PHP Security BasicsPHP Security Basics
PHP Security Basics
 
Migrating from PHP 4 to PHP 5
Migrating from PHP 4 to PHP 5Migrating from PHP 4 to PHP 5
Migrating from PHP 4 to PHP 5
 
Ajax and PHP
Ajax and PHPAjax and PHP
Ajax and PHP
 

Recently uploaded

7 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 20247 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 2024
Danica Gill
 
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
cuobya
 
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
cuobya
 
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
cuobya
 
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
zoowe
 
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
bseovas
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
ufdana
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
keoku
 
Explore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories SecretlyExplore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories Secretly
Trending Blogers
 
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
uehowe
 
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdfMeet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Florence Consulting
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
eutxy
 
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
zyfovom
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC
 
Gen Z and the marketplaces - let's translate their needs
Gen Z and the marketplaces - let's translate their needsGen Z and the marketplaces - let's translate their needs
Gen Z and the marketplaces - let's translate their needs
Laura Szabó
 
Understanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdfUnderstanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdf
SEO Article Boost
 
制作原版1:1(Monash毕业证)莫纳什大学毕业证成绩单办理假
制作原版1:1(Monash毕业证)莫纳什大学毕业证成绩单办理假制作原版1:1(Monash毕业证)莫纳什大学毕业证成绩单办理假
制作原版1:1(Monash毕业证)莫纳什大学毕业证成绩单办理假
ukwwuq
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
Paul Walk
 
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
fovkoyb
 
Ready to Unlock the Power of Blockchain!
Ready to Unlock the Power of Blockchain!Ready to Unlock the Power of Blockchain!
Ready to Unlock the Power of Blockchain!
Toptal Tech
 

Recently uploaded (20)

7 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 20247 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 2024
 
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
 
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
 
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
 
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
 
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
 
Explore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories SecretlyExplore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories Secretly
 
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
 
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdfMeet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
 
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
 
Gen Z and the marketplaces - let's translate their needs
Gen Z and the marketplaces - let's translate their needsGen Z and the marketplaces - let's translate their needs
Gen Z and the marketplaces - let's translate their needs
 
Understanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdfUnderstanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdf
 
制作原版1:1(Monash毕业证)莫纳什大学毕业证成绩单办理假
制作原版1:1(Monash毕业证)莫纳什大学毕业证成绩单办理假制作原版1:1(Monash毕业证)莫纳什大学毕业证成绩单办理假
制作原版1:1(Monash毕业证)莫纳什大学毕业证成绩单办理假
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
 
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
 
Ready to Unlock the Power of Blockchain!
Ready to Unlock the Power of Blockchain!Ready to Unlock the Power of Blockchain!
Ready to Unlock the Power of Blockchain!
 

ZF2 Modules: Events, Services, and of course, modularity

  • 2. Hi! I’m John! • Involved in PHP since circa 1996 • Sr. Architect, Zend Global Services • PHP Core Contributor • ZF Contributor
  • 3. Getting Started  The easiest way to get started in ZF2 is to start with the skeleton application: https://github.com/zendframework/zendskeletonapplication $ composer create-project -sdev -repository-url=“https://packages.zendframework.com” zendframework/skeleton-application /path/to/install
  • 4. ZF2 Modules  In ZF2 modules are a core concept when developing applications. Everything including the application is a module.  Modules can be application-specific or can be written generically and then loaded into the application via composer
  • 5. How are modules structured?
  • 6. How do Modules work?  Every ZF2 module starts with a Module class which describes the module and the things it provides to the application  Services  Event Handlers  Controllers  Routes  Etc.
  • 7. How do Modules work?  Modules also have their own configuration files which can setup default values that are later over-written by the application’s configurations.  Useful for creating module-specific routes, or module-specific configurations, etc.  config/module.config.php
  • 8. How do Modules work?  The module class can implement a number of useful methods  getAutoLoaderConfig() – configure the way classes are autoloaded through this module  getServiceConfig() – set up the way services this module provides can be created and accessed  getModuleDependencies() – Define module dependencies  onBootstrap() – Executed when module is fired up
  • 9. Service Manager  ZF2 applications in general rely heavily on something called the Service Manager to deal with application dependencies  Examples: The DB adapter used by the application is created by the Service Manager
  • 10. Service Manager  Implementing dependencies and components as services allows modules to be completely decoupled from each other  Services are identified by unique ID, which is referenced when the service is required  Customization (i.e. a different DB adapter) can be done simply by over-writing the factory associated with that unique ID
  • 11. Service Manager  In a module services can be defined in various locations  module.config.php (the ‘service_manager’ key)  Module::getServiceConfig() (the programatic approach)
  • 12. Service Manager  How services can be defined  By factory – identify the key to either a class that implements a Factory interface or other callable which returns the instance  By invokable – Simply identify the class associated with this service  Aliases – Services can have an alias for complicated dependency scenarios
  • 13. Using Events  All events are managed through the event manager class(es)  Can be automatically injected into your objects via the Service Locator  Implement the EventManagerAwareInterface
  • 14. Event Managers  The ZF2 Event manager is the primary way modules should communicate with each other  Optionally, also internally  Broadcast Events for others to react to  I.e. “Dispatch”
  • 15. ZF2 Baked in Events  ZF2 uses events throughout its core functionality  Module Manager  Application  Bootstrap, etc.  MVC Events  Routing  Dispatching  Rendering  http://akrabat.com/zend-framework-2/a-list-of-zf2- events/
  • 16. Event Scoping  Events are by default scoped to the local object  Each Event Manger is by default unique to that object  If you want to have events of a different scope you have a few options  Provide a way to get your event manager  Use the more global SharedEventManager
  • 17. Summary  This is a very surface-level exploration into the complex possibilities of ZF2 modules and events, but enough to get started.  Get to know Service Manager and Event Manager very well and they will serve you fantastically, allowing you to write powerful reusable components
  • 18. Any questions? Tell me what you think: http://joind.in/11875 Slides will be available at http://www.slideshare.net/coogle