Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Buses
Search
Magnus Nordlander
October 19, 2015
Programming
0
79
Buses
Command buses and Event buses
Magnus Nordlander
October 19, 2015
Tweet
Share
More Decks by Magnus Nordlander
See All by Magnus Nordlander
How Fervo builds web apps
magnusnordlander
0
140
Monitoring your Application
magnusnordlander
0
500
Git Internals for PHP Developers
magnusnordlander
0
210
HttpFoundation – An excursion in a Symfony2 component
magnusnordlander
1
110
The GIt object model and using Gittern
magnusnordlander
2
1.5k
Other Decks in Programming
See All in Programming
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.3k
CSC307 Lecture 07
javiergs
PRO
0
550
Patterns of Patterns
denyspoltorak
0
1.4k
AI前提で考えるiOSアプリのモダナイズ設計
yuukiw00w
0
230
Honoを使ったリモートMCPサーバでAIツールとの連携を加速させる!
tosuri13
1
180
CSC307 Lecture 09
javiergs
PRO
1
830
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
2.5k
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
130
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
230
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
270
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
280
「ブロックテーマでは再現できない」は本当か?
inc2734
0
970
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Between Models and Reality
mayunak
1
190
Embracing the Ebb and Flow
colly
88
5k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.1k
Into the Great Unknown - MozCon
thekraken
40
2.3k
Balancing Empowerment & Direction
lara
5
890
The Cost Of JavaScript in 2023
addyosmani
55
9.5k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
240
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Leo the Paperboy
mayatellez
4
1.4k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.4k
Transcript
Buses Command buses and Event buses
Magnus Nordlander • PHP consultant specializing in Symfony • Working
at Fervo
Hybrid Bus RTB by Kecko https://www.flickr.com/photos/kecko/8217510887/
Foro Romano by Bert Kaufmann https://www.flickr.com/photos/22746515@N02/8043630550/
The three degrees of doing • Do it yourself •
Ask someone else to do it • Command it be done
Emperor Trajan at Tower Hill by DncnH https://www.flickr.com/photos/duncanh1/9548613224/
Commands • A command is a message which is imperative
in nature • ChangeUserPassword • SendWelcomeEmail
Commands • Always handled by exactly one handler • Task-oriented
• Never returns a value • Required for Command/Query Separation
Command handlers • Immutable services • Handles exactly one command
type each • Only performs the "primary" task related to the event • Remember SRP and OCP
Command bus libs • SimpleBus • Tactician • Broadway
Demo
Why? • Models changes in domain language, capturing intent •
ChangePassword vs UpdateUser • Maps very well to a Task oriented UI
Why? • Reinforces Command-Query Responsibility Separation (CQRS) • Asking a
question should not change the answer • Clearly indicates which code changes system state
Restrictive? • Only performs primary task • No return value
Events
Events • Events are messages which are informational in nature
• UserPasswordWasChanged • WelcomeEmailWasSent
Events • Handled by zero or more listeners • Always
after-the-fact • Cannot change what has already happened
Event listener • Immutable service • Acts upon one type
of event and performs some action • Should be called every time a pertinent event is handled • No listener should be able to stop propagation
Event listener • Example: • WhenNewUserSignedUpSendWelcomeEmail
Event bus libs • SimpleBus • Broadway • Symfony EventDispatcher
• Laravel EventDispatcher • League EventEmitter
Demo
Connecting the dots • Command handlers can emit events •
Event subscribers can issue commands
Learning more • Matthias Noback has a series of excellent
blog posts • http://php-and-symfony.matthiasnoback.nl/tags/ command%20bus/ • Also has a Hexagonal Symfony workshop
Questions?