I switched to using a command bus

  Рет қаралды 4,194

PHP Annotated

PHP Annotated

Күн бұрын

Let's talk about one of my favorite patterns: a command bus. I'll give you five reasons why command busses are awesome.

Пікірлер: 32
@kaleucaminha
@kaleucaminha 5 ай бұрын
Hey man, I'm here from Brazil, I've been working with PHP code since 2007. Your passion about programming and focus on PHP has been a refresh in my love and motivation for this science and art, Thanks
@metaphoricallyspeaking
@metaphoricallyspeaking 6 ай бұрын
It's great to hear someone talking so positively about introducing a Command Bus - the benefits are incredible. I'd still use one if I was building a blog, btw! :)
@jean-marcstrauven2990
@jean-marcstrauven2990 6 ай бұрын
Please, make a article or show a exemple..it's really interesting.
@phpannotated
@phpannotated 6 ай бұрын
I'm drafting a blog post about it as well :)
@batlin
@batlin Ай бұрын
As soon as you described them, I was thinking "this is going to be much more testable", since you have a flatter hierarchy with less direct dependencies. Reminds me a bit of Smalltalk's late binding and the Lua-based game engine Defold's message system -- instead of having a complicated and brittle web of direct dependencies, scripts just broadcast messages and listen for ones they care about.
@Gexsi0
@Gexsi0 6 ай бұрын
I think you should also mention one more benefit. Your commands can be executed synchronously or asynchronously.
@phpannotated
@phpannotated 6 ай бұрын
True, thanks for pointing that out! I actually thought I mentioned it briefly, but I cut that part out last minute 😬
@turboclown
@turboclown 6 ай бұрын
This is very interesting, I hope you'll give some examples in your blog or even open source the code you wrote. I'd love to learn.
@phpannotated
@phpannotated 6 ай бұрын
I plan on writing a post about it as well soon :)
@Plytys
@Plytys 6 ай бұрын
Would like to see an example how you refactor some piece of code to command bus.
@phpannotated
@phpannotated 6 ай бұрын
Very nice idea! I might do a livestream about it soon :)
@Alpheus2
@Alpheus2 5 ай бұрын
@@phpannotated Happy to pair on stream if you want some backup on the refactor plus discussion.
@bambamboole1
@bambamboole1 6 ай бұрын
It’s a very powerful pattern, when you get used to not return stuff from the handlers. Then all of the commands can be easily queued. Connect it via events with websockets to the frontend again and it feels like a super power.
@jelmerprins
@jelmerprins 6 ай бұрын
As a big fan of command busses and the number 1 on the leaderboard of the game, thank you :D I am a bit sad that i have to adjust my deck since something got fixed that was apparently a bug, but the game is still a lot of fun. I would disagree on the crud app though, but maybe that is a symfony vs laravel thing. I also find it useful for crud and with a maker I can easily generate most of the code
@Aerendir
@Aerendir 6 ай бұрын
Can you explain better what do you mean with “with a maker I can easily generate most of the code”? 🙏🏻
@jonashansen2512
@jonashansen2512 6 ай бұрын
A little bit of CQRS goes a long way 😊
@AlexMerlin1985
@AlexMerlin1985 6 ай бұрын
4:44 That missing closing parenthesis after the call to command, though... :)
@phpannotated
@phpannotated 6 ай бұрын
Oh oh 😳
@robwatson826
@robwatson826 6 ай бұрын
I love a command bus. Glad you've seen the light! Interested to know how you handle situations where the command changes some data and you want to send that data back to the client? Do you just make a new query to fetch the updated data? Or do you leave that up to the client to make another request for it?
@phpannotated
@phpannotated 6 ай бұрын
If you follow CQRS, then commands and querying are indeed two concernes that are fully separated. That means no returning from handlers directly. It means that after having dispatched a command, you'll have to re-query the read model manually. I briefly mentioned it in the video, but it's a super interesting topic that's probably worth some content on its own.
@roky2822
@roky2822 6 ай бұрын
@@phpannotated can you recommend good information sources about CQRS. I can google myself sure, but I'm interested which sources would you personally recommend?
@phpannotated
@phpannotated 6 ай бұрын
@@roky2822 I once wrote a blog post where I bundled the talks that got me started, it's a good entry point :) stitcher.io/blog/my-journey-into-event-sourcing If you want to learn more, Greg Young's talks are excellent :)
@anupam.sam9
@anupam.sam9 6 ай бұрын
Can you link your project in the description for better understanding of the full implementation...?
@phpannotated
@phpannotated 6 ай бұрын
It's not open source at the moment. But I will do some livestreams about it in the future :)
@NedumEze
@NedumEze 6 ай бұрын
Never heard of 'Command Boss'. Is it your invention? Any plans for literature or articles on it?
@phpannotated
@phpannotated 6 ай бұрын
😂
@xiCO2k
@xiCO2k 6 ай бұрын
Next refactor should be change from PHPUnit to Pest 🌶
@Hatecultist
@Hatecultist 6 ай бұрын
Little suggestion for the audio: I think a DeHesser is needed
@phpannotated
@phpannotated 6 ай бұрын
Good point, I think it's because I was sick while recording and not breathing properly. I actually have a deesser enabled, but I should have tweaked it some more for this video.
@oladoyinbov
@oladoyinbov 6 ай бұрын
Command bus? Is it like a list of class object, grouped together to be dispatched somewhere else? I am kinda confused here
@BrunoBernard-kn6vt
@BrunoBernard-kn6vt 2 ай бұрын
Please share the repo
PHP 8.4: new without parentheses
13:42
PHP Annotated
Рет қаралды 4,3 М.
🎨 I wrote a code highlighter from scratch
8:31
PHP Annotated
Рет қаралды 4,1 М.
Can You Draw A PERFECTLY Dotted Line?
00:55
Stokes Twins
Рет қаралды 110 МЛН
NERF WAR HEAVY: Drone Battle!
00:30
MacDannyGun
Рет қаралды 55 МЛН
Я нашел кто меня пранкует!
00:51
Аришнев
Рет қаралды 4,5 МЛН
Event-Driven Architecture: Explained in 7 Minutes!
7:18
Alex Hyett
Рет қаралды 90 М.
Vim Tips I Wish I Knew Earlier
23:00
Sebastian Daschner
Рет қаралды 43 М.
AI Makes Minesweeper
2:23
Devra AI
Рет қаралды 1,7 М.
I started from scratch…
7:07
PHP Annotated
Рет қаралды 5 М.
8 Design Patterns | Prime Reacts
22:10
ThePrimeTime
Рет қаралды 392 М.
AWS Fooled Devs & Sabotaged The Industry | Prime Reacts
21:47
ThePrimeTime
Рет қаралды 216 М.
15 Python Libraries You Should Know About
14:54
ArjanCodes
Рет қаралды 372 М.
A new tool for managing PHP extensions | Stream Highlight
6:14
PHP Annotated
Рет қаралды 1,4 М.
What is a Command Bus? #software #architecture
3:51
Metaphorically Speaking
Рет қаралды 1,3 М.
Intel's CPUs Are Failing, ft. Wendell of Level1 Techs
23:59
Gamers Nexus
Рет қаралды 348 М.
КОМПОТ В СОЛО
0:16
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 2,6 МЛН
- А что в креме? - Это кАкАооо! #КондитерДети
0:24
Телеканал ПЯТНИЦА
Рет қаралды 5 МЛН
У Котика Отняли Игрушку 🥺
0:15
ДоброShorts
Рет қаралды 3,8 МЛН
Каха и суп
0:39
К-Media
Рет қаралды 4,8 МЛН
МЛАДШАЯ СЕСТРА И МОРОЖЕНОЕ ИЗ АРБУЗА
0:41
ОЛЯ ПЕРЧИК
Рет қаралды 3 МЛН