PHPackages                             carloswph/gazer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. carloswph/gazer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

carloswph/gazer
===============

An interesting implementation of the PHP Observer pattern.

v1.0.0(5y ago)110MITPHP

Since Mar 7Pushed 5y ago1 watchersCompare

[ Source](https://github.com/carloswph/gazer)[ Packagist](https://packagist.org/packages/carloswph/gazer)[ RSS](/packages/carloswph-gazer/feed)WikiDiscussions main Synced yesterday

READMEChangelog (2)DependenciesVersions (3)Used By (0)

Gazer
=====

[](#gazer)

An easier and practical implementation of the Observer pattern in PHP. Work with abstracts rather than implementing interfaces.

Installation
============

[](#installation)

`composer require carloswph/gazer`

Usage
=====

[](#usage)

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:

```
use Gazer\Subject;
use Gazer\Gazer;

require __DIR__ . '/vendor/autoload.php';

// This is the subject class
class A extends Subject {

}
// This is one observer - but you could use the same logic
// for more observers, like classes C or D, for instance
class B extends Gazer {

}
```

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.

```
$a = new A();
$b = new B();

// Now, all we need to do for B to "observer" A
// is using the method attach() from A

$a->attach($b);

// Ready! If A uses the method notify(), then a method
// update() in B will be ran, and B gets the A object
// held in the variable $subject, thus...

$a->notify(); // B gets A object immediately
```

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.

```
use Gazer\Subject;
use Gazer\Gazer;

require __DIR__ . '/vendor/autoload.php';

class A extends Subject {

	public $example = 'Observed';

	public function __construct() {

		echo "Subject\n";
	}
}

class B extends Gazer {

	public function info() {

		echo $this->subject->example;
	}

}

$a = new A();
$b = new B();

// The only thing you can see is the word "Subject" echoed
// But now, let's put B to observe A

$a->attach($b);
$a->notify();

// As B is observing and A has notified all observers, so
// now we can manipulate the A object, which has been updated
// and held in the property $subject of B

$b->info(); // Prints "Observed"
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 63.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1890d ago

Major Versions

v0.1-beta → v1.0.02021-03-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/13c91dcf5209989038da335ba42538fa84670bf27400f220d182a76e0a720b74?d=identicon)[carloswph](/maintainers/carloswph)

---

Top Contributors

[![carloswph](https://avatars.githubusercontent.com/u/78516217?v=4)](https://github.com/carloswph "carloswph (7 commits)")[![meuppt](https://avatars.githubusercontent.com/u/37983141?v=4)](https://github.com/meuppt "meuppt (4 commits)")

### Embed Badge

![Health badge](/badges/carloswph-gazer/health.svg)

```
[![Health](https://phpackages.com/badges/carloswph-gazer/health.svg)](https://phpackages.com/packages/carloswph-gazer)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
