Download the PHP package carloswph/gazer without Composer
On this page you can find all versions of the php package carloswph/gazer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Short Description An interesting implementation of the PHP Observer pattern.
All versions of gazer with dependencies
Informations about the package gazer
An easier and practical implementation of the Observer pattern in PHP. Work with abstracts rather than implementing interfaces.
composer require carloswph/gazer
Simple: instead of creating yourself abstracts or implementing pairs SplSubject and SplObserver in multiple classes, all you need to do is extending the classes Gazer\Subject and Gazer\Gazer in your subject class and the observers, respectivelly. Let's use a quick example:
At this moment, the classes A and B area already able to perform their roles in the observer pattern. Logic follows the pattern regular interfaces SplSubject and SplObserver, so the methods will be exactly the ones you expected.
Let's use the same classes, but now with some methods and properties. We'll create a property $example in A and a random method in B, which will apply any logic using the native property $subject.