From the course: PHP: Design Patterns
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Introducing the publish/subscriber pattern - PHP Tutorial
From the course: PHP: Design Patterns
Introducing the publish/subscriber pattern
- Now let's talk about the publish/subscriber pattern or simply, Pub/Sub. It's one of the more unique patterns we'll cover in this course in that it doesn't deal with the creation of objects or modifying their behavior. Instead it deals with sending and receiving commands to those objects. The problem here is simple. When we build systems the components have to link to one another. The general way of doing this is hard coding connections between the components. A calls B, which calls C. This all works out well until you need to add components D and E. You end up with more and more connections which becomes impossible to manage. We need a way to auto wire these components without explicitly wiring them. Luckily there's a pattern for that, Pub/Sub. The concept is simple. You have some shared channel or communication bus where publishers send their messages. Then you have a series of subscribers that are listening to that channel for messages they care about. When they detect messages…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
(Locked)
Introducing the publish/subscriber pattern2m 4s
-
(Locked)
Exploring a use case for the publish/subscriber pattern1m 57s
-
(Locked)
The publish/subscriber pattern in action1m 6s
-
(Locked)
Challenge: Apply the publish/subscriber pattern51s
-
(Locked)
Solution: Apply the publish/subscriber pattern1m 4s
-
(Locked)
-
-
-
-