SlideShare a Scribd company logo
Event Dispatcher
Symfony 2.X
- Yogesh Salvi
Introduction
● Coupling
● Tightly Coupled and Loosely Coupled System
● Event
● Event Dispatcher
○ Open Ear Event Dispatcher - Listener
○ Open Mouth Event Dispatcher - Talker
● Event-Driven Architecture
● Understand the terms
○ Listener
○ Subscriber
● Demo
● Questions?
Coupling
Coupling
● A device for connecting parts.
● In Software Terminology
○ Coupling is the degree of interdependence between software entities.
○ It measure of how closely connected two or more software entities.
○ It shows strength of the relationships between software entities.
○ Coupling is usually contrasted with cohesion.
○ Low coupling often correlates with high cohesion, and vice versa.
○ Coupling can be "low" (also "loose" and "weak") or "high" (also "tight" and "strong")
Tightly and Loosely Coupled
System
Tightly Coupled System
● Tight coupling is when a group of entities are highly dependent on one
another.
● This scenario arises when a class assumes too many responsibilities,
● When one concern is spread over many entities rather than having its own
class.
● When entity don’t follow Single Responsibility Principle and separation of
concerns.
F
E
D
C
A
B
Tightly Coupled System - Disadvantages
● A change in one module usually forces a ripple effect of changes in other
modules.
● Assembly of modules might require more effort and/or time due to the
increased inter-module dependency.
● A particular module might be harder to reuse and/or test because dependent
modules must be included.
Loosely Coupled System
● Loose coupling is achieved by means of a design that promotes
single-responsibility and separation of concerns.
● A loosely-coupled entity can be consumed and tested independently of other
entities.
● Loose coupling is often a sign of a well-structured computer system and a
good design.
● when it combined with high cohesion, it supports the general goals of high
readability and maintainability.
Loosely Coupled System
● Components can be replaced with alternative implementations that provide
the same services.
● Components in a loosely coupled system are less constrained to the same
platform, language, operating system, or build environment.
F
E
D
C
A
B
Event
Event
An event can be defined as
"a significant change in state"
Event - Structure
● Event Header
○ The event header might include information such as event name, time stamp for the event,
and type of event.
● Event Body
○ The event body provides the details of the state change detected. An event body should not
be confused with the pattern or the logic that may be applied in reaction to the occurrence of
the event itself.
Event
Dispatcher
Dispatcher
● Dispatchers are communications personnel
responsible for receiving and transmitting pure and
reliable messages.
● A number of organizations, including police and fire
departments, emergency medical services, railroads,
etc, use dispatchers to relay information and
coordinate their operations.
Event Dispatcher
Event Dispatcher
● It provides way which allow application components to communicate with
each other by dispatching events and listening to them.
● It is the only way to use communication where you don't care about the
target object.
● Target object may or may not be exists.
● They will listen to any messages that are being broadcasted.
Open Ear Event Dispatcher
Listener
Open Ear Event Dispatcher - Listener
● This type of event dispatchers are like
message-sponges.
● They will listen to any messages that are
being broadcasted.
Open Mouth Event
Dispatcher - Talker
Open Mouth Event Dispatcher - Talker
● This type of event dispatchers are like
loudmouths.
● They will broadcast any message to anyone
who is listening on demand.
Event-Driven Architecture
Event-Driven Architecture
Event-Driven Architecture aims at promoting
Loosely Coupled System.
● It is a programming paradigm in which the flow of the program is
determined by series of events.
● It is a software architecture pattern promoting the creation, detection,
consumption of, and reaction to events.
Event-Driven Architecture
Event Generator
Event Dispatcher
Event Handler 2Event Handler 1 Event Handler 3
Event Open Ear Event
Dispatcher
Open Mouth
Event Dispatcher
Event-Driven Architecture
● A listener tells a central dispatcher object that it wants to listen to the some
specific event (X).
● At some point, the event generator tells the dispatcher object to dispatch the
event (X), passing with it an Event object.
● Event object itself often contains data about the event being dispatched.
● The dispatcher notifies (i.e. calls a method on) all listeners of the event (X).
Listener vs Subscriber
Listener
● It is signed up specifying the events on which it listens (i.e. Service
Definition).
● It can also listen on several events simply by adding more tags in service
definition.
● Same event listener can be bind to different events without modifying class.
Simply by changing service definition.
● An event listeners are bind at the time of bootstrapping.
● Listeners are more flexible because bundles can enable or disable each of
them conditionally depending on some configuration value.
Subscriber
● The Subscriber has a method telling the dispatcher what events it is listening
to.
● It keeps the knowledge of the events in the class rather than in the service
definition.
● You can change the events a subscriber is registered for, at runtime and
even after registering the subscriber by changing the return value of
getSubscribedEvents method.
● Subscribers are easier to reuse because the knowledge of the events is kept
in the class rather than in the service definition. This is the reason why
Symfony uses subscribers internally;
Listener vs Subscriber
Eventually
both Listeners and Subscribers are
registered as
“Listeners”.
Debugging Event Listeners
You can find out what listeners are registered in the event dispatcher using the
console:
You can get registered listeners for a particular event by specifying its name:
# php bin/console debug:event-dispatcher
# php bin/console debug:event-dispatcher kernel.exception
Demo
Questions???
Thank You!
Yogesh M Salvi
References:
● https://en.wikipedia.org/wiki/Loose_coupl
ing
● https://en.wikipedia.org/wiki/Event-drive
n_architecture
● http://symfony.com/doc/current/compone
nts/event_dispatcher.html

More Related Content

PDF
게임제작개론 8
PPTX
[TGDF 2019] Mali GPU Architecture and Mobile Studio
PDF
NDC2013 - 인디게임 프로젝트 중도에 포기하지 않는 방법
PDF
DEBUG 裝屌指南 - 那些看起來高級的 LLDB 手勢
PDF
게임제작개론 : #8 게임 제작 프로세스
PDF
게임제작개론 : #0 과목소개
PPT
게임 기획과 Oop
PPTX
[NDC2019] 전소현&장기은 - 시나리오 기획자는 대사만 잘쓰면 되는 거 아닌가요? ㅇㅅㅇ
게임제작개론 8
[TGDF 2019] Mali GPU Architecture and Mobile Studio
NDC2013 - 인디게임 프로젝트 중도에 포기하지 않는 방법
DEBUG 裝屌指南 - 那些看起來高級的 LLDB 手勢
게임제작개론 : #8 게임 제작 프로세스
게임제작개론 : #0 과목소개
게임 기획과 Oop
[NDC2019] 전소현&장기은 - 시나리오 기획자는 대사만 잘쓰면 되는 거 아닌가요? ㅇㅅㅇ

What's hot (20)

PDF
[NDC07] 게임 개발에서의 클라이언트 보안 - 송창규
PDF
유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) Unite Seoul Ver.
PDF
Multiplayer Game Sync Techniques through CAP theorem
PPT
Game development Pre-Production
PDF
MMORPGで考えるレベルデザイン
PDF
[야생의 땅: 듀랑고] 서버 아키텍처 Vol. 2 (자막)
PDF
국내인디게임개발자의현실
PDF
게임제작개론 : #7 팀 역할과 게임 리소스에 대한 이해
PDF
모바일 게임기획 따라하며 배우기
PDF
[IGC2018] 펄어비스 김광삼 - 대면 커뮤니케이션 주도의 게임 디자인과 게임 개발법
PDF
NHN NEXT 게임 전공 소개
PDF
Pwning in c++ (basic)
PPTX
NDC 11 자이언트 서버의 비밀
PDF
[NDC2016] TERA 서버의 Modern C++ 활용기
PPTX
02. 게임기획, 재미를 향한 끝없는 여정
PDF
NDC 2017 키노트: 이은석 - 다가오는 4차 산업혁명 시대의 게임개발
PPTX
게임 개발 파이프라인과 시스템 기획(공개용)
PDF
게임 시스템 디자인 시작하기
PDF
KGC 2014 프로파일러를 이용한 게임 클라이언트 최적화
PDF
Data Driven Game Design
[NDC07] 게임 개발에서의 클라이언트 보안 - 송창규
유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) Unite Seoul Ver.
Multiplayer Game Sync Techniques through CAP theorem
Game development Pre-Production
MMORPGで考えるレベルデザイン
[야생의 땅: 듀랑고] 서버 아키텍처 Vol. 2 (자막)
국내인디게임개발자의현실
게임제작개론 : #7 팀 역할과 게임 리소스에 대한 이해
모바일 게임기획 따라하며 배우기
[IGC2018] 펄어비스 김광삼 - 대면 커뮤니케이션 주도의 게임 디자인과 게임 개발법
NHN NEXT 게임 전공 소개
Pwning in c++ (basic)
NDC 11 자이언트 서버의 비밀
[NDC2016] TERA 서버의 Modern C++ 활용기
02. 게임기획, 재미를 향한 끝없는 여정
NDC 2017 키노트: 이은석 - 다가오는 4차 산업혁명 시대의 게임개발
게임 개발 파이프라인과 시스템 기획(공개용)
게임 시스템 디자인 시작하기
KGC 2014 프로파일러를 이용한 게임 클라이언트 최적화
Data Driven Game Design
Ad

Similar to Event Dispatcher (20)

PPTX
Event Driven Software Architecture Pattern
PPTX
Event driven systems
PDF
Workflows via Event driven architecture
PPT
Aaai 2011 event processing tutorial
PPT
Vldb 2010 event processing tutorial
PPT
Learning Vague Knowledge From Socially Generated Content in an Enterprise Fra...
ODP
AULT : Agent based User simulation
PPTX
PATTERNS06 - The .NET Event Model
PPTX
context aware.pptx
PPTX
pattern v
PPTX
Architectural styles class 1
PDF
An Introduction to Software Architecture - Summary
PDF
A Whirlwind Tour of Spatial Joins
PPTX
Testing Event Driven Architecture Presentation
PPTX
Testing Event Driven Architecture Presentation
PPTX
EVENT DRIVEN PROGRAMMING SWING APPLET AWT
PDF
Reactive - Is it really a Magic Pill?
PDF
Tlpi chapter 38 writing secure privileged programs
PDF
Reactive systems
PPTX
Understanding concurrency
Event Driven Software Architecture Pattern
Event driven systems
Workflows via Event driven architecture
Aaai 2011 event processing tutorial
Vldb 2010 event processing tutorial
Learning Vague Knowledge From Socially Generated Content in an Enterprise Fra...
AULT : Agent based User simulation
PATTERNS06 - The .NET Event Model
context aware.pptx
pattern v
Architectural styles class 1
An Introduction to Software Architecture - Summary
A Whirlwind Tour of Spatial Joins
Testing Event Driven Architecture Presentation
Testing Event Driven Architecture Presentation
EVENT DRIVEN PROGRAMMING SWING APPLET AWT
Reactive - Is it really a Magic Pill?
Tlpi chapter 38 writing secure privileged programs
Reactive systems
Understanding concurrency
Ad

Recently uploaded (20)

PDF
System and Network Administraation Chapter 3
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Understanding Forklifts - TECH EHS Solution
PDF
top salesforce developer skills in 2025.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
System and Network Administration Chapter 2
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
assetexplorer- product-overview - presentation
PDF
Cost to Outsource Software Development in 2025
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
history of c programming in notes for students .pptx
PDF
PTS Company Brochure 2025 (1).pdf.......
System and Network Administraation Chapter 3
Design an Analysis of Algorithms I-SECS-1021-03
Understanding Forklifts - TECH EHS Solution
top salesforce developer skills in 2025.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
wealthsignaloriginal-com-DS-text-... (1).pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
System and Network Administration Chapter 2
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Why Generative AI is the Future of Content, Code & Creativity?
Adobe Illustrator 28.6 Crack My Vision of Vector Design
assetexplorer- product-overview - presentation
Cost to Outsource Software Development in 2025
Digital Systems & Binary Numbers (comprehensive )
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Softaken Excel to vCard Converter Software.pdf
history of c programming in notes for students .pptx
PTS Company Brochure 2025 (1).pdf.......

Event Dispatcher

  • 2. Introduction ● Coupling ● Tightly Coupled and Loosely Coupled System ● Event ● Event Dispatcher ○ Open Ear Event Dispatcher - Listener ○ Open Mouth Event Dispatcher - Talker ● Event-Driven Architecture ● Understand the terms ○ Listener ○ Subscriber ● Demo ● Questions?
  • 4. Coupling ● A device for connecting parts. ● In Software Terminology ○ Coupling is the degree of interdependence between software entities. ○ It measure of how closely connected two or more software entities. ○ It shows strength of the relationships between software entities. ○ Coupling is usually contrasted with cohesion. ○ Low coupling often correlates with high cohesion, and vice versa. ○ Coupling can be "low" (also "loose" and "weak") or "high" (also "tight" and "strong")
  • 5. Tightly and Loosely Coupled System
  • 6. Tightly Coupled System ● Tight coupling is when a group of entities are highly dependent on one another. ● This scenario arises when a class assumes too many responsibilities, ● When one concern is spread over many entities rather than having its own class. ● When entity don’t follow Single Responsibility Principle and separation of concerns. F E D C A B
  • 7. Tightly Coupled System - Disadvantages ● A change in one module usually forces a ripple effect of changes in other modules. ● Assembly of modules might require more effort and/or time due to the increased inter-module dependency. ● A particular module might be harder to reuse and/or test because dependent modules must be included.
  • 8. Loosely Coupled System ● Loose coupling is achieved by means of a design that promotes single-responsibility and separation of concerns. ● A loosely-coupled entity can be consumed and tested independently of other entities. ● Loose coupling is often a sign of a well-structured computer system and a good design. ● when it combined with high cohesion, it supports the general goals of high readability and maintainability.
  • 9. Loosely Coupled System ● Components can be replaced with alternative implementations that provide the same services. ● Components in a loosely coupled system are less constrained to the same platform, language, operating system, or build environment. F E D C A B
  • 10. Event
  • 11. Event An event can be defined as "a significant change in state"
  • 12. Event - Structure ● Event Header ○ The event header might include information such as event name, time stamp for the event, and type of event. ● Event Body ○ The event body provides the details of the state change detected. An event body should not be confused with the pattern or the logic that may be applied in reaction to the occurrence of the event itself.
  • 13. Event
  • 15. Dispatcher ● Dispatchers are communications personnel responsible for receiving and transmitting pure and reliable messages. ● A number of organizations, including police and fire departments, emergency medical services, railroads, etc, use dispatchers to relay information and coordinate their operations.
  • 17. Event Dispatcher ● It provides way which allow application components to communicate with each other by dispatching events and listening to them. ● It is the only way to use communication where you don't care about the target object. ● Target object may or may not be exists. ● They will listen to any messages that are being broadcasted.
  • 18. Open Ear Event Dispatcher Listener
  • 19. Open Ear Event Dispatcher - Listener ● This type of event dispatchers are like message-sponges. ● They will listen to any messages that are being broadcasted.
  • 21. Open Mouth Event Dispatcher - Talker ● This type of event dispatchers are like loudmouths. ● They will broadcast any message to anyone who is listening on demand.
  • 23. Event-Driven Architecture Event-Driven Architecture aims at promoting Loosely Coupled System. ● It is a programming paradigm in which the flow of the program is determined by series of events. ● It is a software architecture pattern promoting the creation, detection, consumption of, and reaction to events.
  • 24. Event-Driven Architecture Event Generator Event Dispatcher Event Handler 2Event Handler 1 Event Handler 3 Event Open Ear Event Dispatcher Open Mouth Event Dispatcher
  • 25. Event-Driven Architecture ● A listener tells a central dispatcher object that it wants to listen to the some specific event (X). ● At some point, the event generator tells the dispatcher object to dispatch the event (X), passing with it an Event object. ● Event object itself often contains data about the event being dispatched. ● The dispatcher notifies (i.e. calls a method on) all listeners of the event (X).
  • 27. Listener ● It is signed up specifying the events on which it listens (i.e. Service Definition). ● It can also listen on several events simply by adding more tags in service definition. ● Same event listener can be bind to different events without modifying class. Simply by changing service definition. ● An event listeners are bind at the time of bootstrapping. ● Listeners are more flexible because bundles can enable or disable each of them conditionally depending on some configuration value.
  • 28. Subscriber ● The Subscriber has a method telling the dispatcher what events it is listening to. ● It keeps the knowledge of the events in the class rather than in the service definition. ● You can change the events a subscriber is registered for, at runtime and even after registering the subscriber by changing the return value of getSubscribedEvents method. ● Subscribers are easier to reuse because the knowledge of the events is kept in the class rather than in the service definition. This is the reason why Symfony uses subscribers internally;
  • 29. Listener vs Subscriber Eventually both Listeners and Subscribers are registered as “Listeners”.
  • 30. Debugging Event Listeners You can find out what listeners are registered in the event dispatcher using the console: You can get registered listeners for a particular event by specifying its name: # php bin/console debug:event-dispatcher # php bin/console debug:event-dispatcher kernel.exception
  • 31. Demo
  • 33. Thank You! Yogesh M Salvi References: ● https://en.wikipedia.org/wiki/Loose_coupl ing ● https://en.wikipedia.org/wiki/Event-drive n_architecture ● http://symfony.com/doc/current/compone nts/event_dispatcher.html