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
77
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
130
Monitoring your Application
magnusnordlander
0
480
Git Internals for PHP Developers
magnusnordlander
0
200
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
なぜ今、Terraformの本を書いたのか? - 著者陣に聞く!『Terraformではじめる実践IaC』登壇資料
fufuhu
4
420
Flutter로 Gemini와 MCP를 활용한 Agentic App 만들기 - 박제창 2025 I/O Extended Seoul
itsmedreamwalker
0
110
自作OSでDOOMを動かしてみた
zakki0925224
1
820
DataformでPythonする / dataform-de-python
snhryt
0
150
プロダクトという一杯を作る - プロダクトチームが味の責任を持つまでの煮込み奮闘記
hiliteeternal
0
410
DatadogのArchived LogsをSnowflakeで高速に検索する方法(Archive Searchでオワコンにならないことを祈って) / How to search Datadog Archived Logs quickly with Snowflake (hoping Datadog Archive Search doesn’t make this obsolete)
civitaspo
0
110
Dart 参戦!!静的型付き言語界の隠れた実力者
kno3a87
0
170
副作用と戦う PHP リファクタリング ─ ドメインイベントでビジネスロジックを解きほぐす
kajitack
3
530
CLI ツールを Go ライブラリ として再実装する理由 / Why reimplement a CLI tool as a Go library
ktr_0731
3
970
抽象化という思考のツール - 理解と活用 - / Abstraction-as-a-Tool-for-Thinking
shin1x1
1
940
オホーツクでコミュニティを立ち上げた理由―地方出身プログラマの挑戦 / TechRAMEN 2025 Conference
lemonade_37
1
440
PHPUnitの限界をPlaywrightで補完するテストアプローチ
yuzneri
0
380
Featured
See All Featured
Designing Experiences People Love
moore
142
24k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
750
Rails Girls Zürich Keynote
gr2m
95
14k
Bash Introduction
62gerente
614
210k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Into the Great Unknown - MozCon
thekraken
40
2k
A Tale of Four Properties
chriscoyier
160
23k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
332
22k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
1k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
790
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
How to train your dragon (web standard)
notwaldorf
96
6.2k
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?