Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
490
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
愛される翻訳の秘訣
kishikawakatsumi
3
330
まだ間に合う!Claude Code元年をふりかえる
nogu66
5
850
エディターってAIで操作できるんだぜ
kis9a
0
740
LLMで複雑な検索条件アセットから脱却する!! 生成的検索インタフェースの設計論
po3rin
4
840
SwiftUIで本格音ゲー実装してみた
hypebeans
0
420
Cell-Based Architecture
larchanjo
0
130
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
120
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
7
2.2k
TestingOsaka6_Ozono
o3
0
170
俺流レスポンシブコーディング 2025
tak_dcxi
14
8.9k
Deno Tunnel を使ってみた話
kamekyame
0
150
ELYZA_Findy AI Engineering Summit登壇資料_AIコーディング時代に「ちゃんと」やること_toB LLMプロダクト開発舞台裏_20251216
elyza
2
270
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
The Cult of Friendly URLs
andyhume
79
6.7k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Context Engineering - Making Every Token Count
addyosmani
9
540
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
196
70k
Thoughts on Productivity
jonyablonski
73
5k
How to Think Like a Performance Engineer
csswizardry
28
2.4k
Are puppies a ranking factor?
jonoalderson
0
2.3k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.5k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
54k
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?