PHPackages                             subcosm/observatory - 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. subcosm/observatory

ActiveLibrary

subcosm/observatory
===================

General Observation Pattern Component

v1.1(9y ago)145MITPHPPHP &gt;=7.1

Since Apr 4Pushed 9y ago2 watchersCompare

[ Source](https://github.com/subcosm/observatory)[ Packagist](https://packagist.org/packages/subcosm/observatory)[ RSS](/packages/subcosm-observatory/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

observatory
===========

[](#observatory)

General Observation Pattern Component

[![Build Status](https://camo.githubusercontent.com/dac206978ed2e80c055e06ef7770b9c75e33340f24102c033747b425ac988f5b/68747470733a2f2f7472617669732d63692e6f72672f737562636f736d2f6f627365727661746f72792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/subcosm/observatory)[![codecov](https://camo.githubusercontent.com/80cd9a21911a944eeea02cbce85f8c991bf004f00622ed17a97baa2f1f4eb045/68747470733a2f2f636f6465636f762e696f2f67682f737562636f736d2f6f627365727661746f72792f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/subcosm/observatory)[![SensioLabsInsight](https://camo.githubusercontent.com/458deb1715250379d56f29d89ca1084c82cf48965bf713353215c73435413395/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f63343864656538302d633831322d346566302d383432362d3136346163386332646262332f6d696e692e706e67)](https://insight.sensiolabs.com/projects/c48dee80-c812-4ef0-8426-164ac8c2dbb3)[![Code Climate](https://camo.githubusercontent.com/be8986f27e991f2d52705a316d0d70e608a10ad5ef467735f043aac0768f29a6/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f737562636f736d2f6f627365727661746f72792e706e67)](https://codeclimate.com/github/subcosm/observatory)[![Gittip](https://camo.githubusercontent.com/d53d5a8bb4923b56b1dbe791f52e66ce0e9ba91c9daedb1939429ab945fe3c98/687474703a2f2f696d672e736869656c64732e696f2f6769747469702f737562636f736d2e737667)](https://gittip.com/subcosm/)

### What is observatory?

[](#what-is-observatory)

Observatory is a general interface orchestration for observable objects using a container for data transport. It's inspired by the `SplObserver` implementation of [PHP](https://php.net).

### What is the goal of observatory?

[](#what-is-the-goal-of-observatory)

Providing an easy to use, easy to understand, lightweight event hub to specific implementations without provided methods for each event invoker registration.

### How to use it?

[](#how-to-use-it)

Subcosm Observatory is available at [Packagist](https://packagist/subcosm/observatory):

```
# composer require subcosm/observatory ~1.0

```

#### Creating the Observable Object

[](#creating-the-observable-object)

```
use Subcosm\Observable\{
    ObservableInterface,
    ObservableTrait,
    AbstractObservationContainer as Container
};

class Foo implements ObservableInterface {
    use ObservableTrait;

    public function firstAction()
    {
        $message = 'Hello from firstAction!';

        $container = new class($this, __METHOD__, $message) extends Container {

            protected $message;

            public function __construct($object, string $stage, string $message)
            {
                $this->message = $message;

                parent::__construct($object, $stage);
            }

            public function getMessage()
            {
                $this->message;
            }
        };

        $this->notify($container);
    }

    public function secondAction()
    {
        $message = 'Another hello from secondAction!';

        $container = new class($this, __METHOD__, $message) extends Container {

            protected $message;

            public function __construct($object, string $stage, string $message)
            {
                $this->message = $message;

                parent::__construct($object, $stage);
            }

            public function getMessage()
            {
                $this->message;
            }
        };

        $this->notify($container);
    }
}
```

#### Creating an Observer

[](#creating-an-observer)

```
use Subcosm\Observable\{
    ObserverInterface,
    ObservationContainerInterface as Container
};

class EchoMessageObserver implements ObserverInterface {

    public function update(Container $container)
    {
        echo $container->getMessage().PHP_EOL;
    }

}
```

#### Using the Observable and Observer

[](#using-the-observable-and-observer)

```
$observable = new Foo;

$observer = new EchoMessageObserver;

$observable->attach($observer);

$observable->firstAction();
$observable->secondAction();
```

Results in:

```
Hello from firstAction!
Another hello from secondAction!

```

### Package Stability and Maintainers

[](#package-stability-and-maintainers)

This package is considered stable. The maintainers of this package are:

- [Matthias Kaschubowski](https://github.com/nhlm)

### License

[](#license)

This package is licensed under the [MIT-License](LICENSE).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~1 days

Total

3

Last Release

3324d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/227851c0e1b423c7d7e6500c5ee45ff9911bbe1c53fff67b011fb055b9eeed43?d=identicon)[nihylum](/maintainers/nihylum)

---

Top Contributors

[![nhlm](https://avatars.githubusercontent.com/u/23406211?v=4)](https://github.com/nhlm "nhlm (17 commits)")

---

Tags

observer-pattern

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/subcosm-observatory/health.svg)

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

PHPackages © 2026

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