PHPackages                             cottagelabs/coar-notifications - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. cottagelabs/coar-notifications

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

cottagelabs/coar-notifications
==============================

A library and server-side implementation supporting a limited number of the COAR Notify pattern objects. Server-side implementation assumes MySQL. If you are looking for a full, generic implementation of the COAR Notify protocol see https://packagist.org/packages/cottagelabs/coarnotify

0.9.70(3y ago)0353↑100%2MITPHPPHP &gt;=7.4

Since Dec 4Pushed 1y ago3 watchersCompare

[ Source](https://github.com/CottageLabs/coar-notifications)[ Packagist](https://packagist.org/packages/cottagelabs/coar-notifications)[ RSS](/packages/cottagelabs-coar-notifications/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (7)Versions (12)Used By (0)

COAR Notification Manager
=========================

[](#coar-notification-manager)

The [COAR Notification](https://notify.coar-repositories.org/) (CNs) Manager can both act as an inbox that receives notification as well as send notifications. CNs are [Linked Data Notifications](https://www.w3.org/TR/2017/REC-ldn-20170502/) that have a [Activity Streams 2.0](https://www.w3.org/TR/activitystreams-core/) like structure (see Appendix for an example of a COAR Notification).

CNs do not have a final specification, but [*notification patterns*](https://notify.coar-repositories.org/patterns/), further exemplified in [*example scenarios*](https://notify.coar-repositories.org/scenarios/) give good guidance.

It is written in PHP 7.4 with [Guzzle](https://docs.guzzlephp.org/en/stable/) (wrapped around [cURL](https://www.php.net/manual/en/book.curl.php)) and [JSON](https://www.php.net/manual/en/book.json.php). It uses [Doctrine](https://www.doctrine-project.org/) for persistence in a database, [Monolog](https://github.com/Seldaek/monolog) for logging, [ramsey/uuid](https://github.com/ramsey/uuid) to generate v4 UUIDs and Guzzle to send notifications (see `composer.json` for version numbers).

This Notification Manager was originally designed to support scenarios # 1, 2, 3, 4 and 9 that involve three different types of activities: announcing a review, requesting a review and announcing an endorsement. This was later expanded to include: acknowledging and accepting, acknowledging and rejecting, announcing an ingest, announcing a relationship, requesting an endorsement, requesting an ingest and retracting an offer for a total of ten different notication patterns.

The ten supported patterns in alphabetical order:

- [Acknowledge and Accept](https://notify.coar-repositories.org/patterns/acknowledge-acceptance/)
- [Acknowledge and Reject](https://notify.coar-repositories.org/patterns/acknowledge-rejection/)
- [Announce Endorsement](https://notify.coar-repositories.org/patterns/announce-endorsement/)
- [Announce Ingest](https://notify.coar-repositories.org/patterns/announce-ingest/)
- [Announce Relationship](https://notify.coar-repositories.org/patterns/announce-relationship/)
- [Announce Review](https://notify.coar-repositories.org/patterns/announce-review/)
- [Request Endorsement](https://notify.coar-repositories.org/patterns/request-endorsement/)
- [Request Ingest](https://notify.coar-repositories.org/patterns/request-ingest/)
- [Request Review](https://notify.coar-repositories.org/patterns/request-review/)
- [Retract Offer](https://notify.coar-repositories.org/patterns/undo-offer/)

Installation &amp; setup
------------------------

[](#installation--setup)

The easiest way to install is to use Composer.

`$ composer require cottagelabs/coar-notifications`

To set up the inbox you need a MySQL/MariaDB database.

Create the database schema by creating the file `cli-config.php` in the project's root folder (see [Doctrine documentation](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/configuration.html)and example in the `docker` folder) and running: `$ php vendor/bin/doctrine orm:schema-tool:create` to create the database schema (`docker exec coar_notify_php php vendor/bin/doctrine orm:schema-tool:create` from outside the container) and the Dockerfile will run an Apache 2 web server.

Usage
-----

[](#usage)

This module does not address the [discovery part](https://www.w3.org/TR/2017/REC-ldn-20170502/#discovery) of the LDN recommendation. That is up to the developer of the web application.

A few configuration parameters can be passed to `COARNotificationManager`:

VariableDescriptionDefault value`conn`either [DBAL connnection parameters in an array](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#configuration) or an already established DBAL Connection`logger`A Monolog logger objectNULL (no logging)`id`the system's URL`$_SERVER['SERVER_NAME']``inbox_url`the inbox's URL`$_SERVER['HTTP_HOST'] + $_SERVER['PHP_SELF']`Client settings`timeout`for how long the client attempts to post a notification, in seconds5`user_agent`the client's user agent used to identify the client'PHP COAR Notification Manager'In the following examples we will assume we have created a COARNotificationManager instances like so:

```
$conn = array('host'     => '127.0.0.1',
    'driver'   => 'pdo_mysql',
    'user'     => 'root',
    'password' => 'my-secret-pw',
    'dbname'   => 'coar_notifications',
);

$logger = new Logger('NotifyCOARLogger');
$handler = new RotatingFileHandler(__DIR__ . '/log/NotifyCOARLogger.log', 0, Logger::DEBUG, true, 0664);
$formatter = new LineFormatter(null, null, false, true);
$handler->setFormatter($formatter);
$logger->pushHandler($handler);

// Initialising a COARNotificationManager
$coarNotificationManager = new COARNotificationManager($conn, $logger);
```

A table named `notifications` is assumed to have been created (see Installation &amp; setup above). This table will contain all notifications using a [single table inheritance](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html#single-table-inheritance) mapping discriminator column named `direction`, to differentiate between `INBOUND` and `OUTBOUND`notifications.

The COAR Notification manager is not aware of requests, these must be handled by the web application's logic. The manager provides appropriate responses:

### Options

[](#options)

As [per the LDN recommendation](https://www.w3.org/TR/2017/REC-ldn-20170502/#sender), a sender may may use an OPTIONS request to determine the RDF content types accepted by the server. This method will set the response headers `Allow` and `Accept-Post`.

It is up to the web application to determine that a OPTIONS request has been made.

Example:

```
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
    $coarNotificationManager->setOptionsResponseHeaders();
}
```

### Post

[](#post)

This method attempts to decode a JSON payload and depending on it's success, will respond with one of HTTP codes:

- 400 if JSON is malformed
- 422 if notification is not valid or an error occurs when persisting the notification
- 201 if notification is successfully received and persisted
- 415 if an unsupported media type is used

Example:

```
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $coarNotificationManager->getPostResponse();
}
```

### Get

[](#get)

As [per the LDN recommendation](https://www.w3.org/TR/2017/REC-ldn-20170502/#consumer), this method lists the inbox's contents. There is no pagination method available via the COAR Notification Manager. However Doctrine [supports pagination](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/tutorials/pagination.html).

Example:

```
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    $response = $coarNotificationManager->getGetResponse();

    // Optionally manipulate $response
    // ...

    echo $response;
}
```

Example output:

```
{
  "@context": "http://www.w3.org/ns/ldp",
  "@id": "https://overlay-journal.com",
  "contains": [
    "https://overlay-journal.com/inbox/b5df022a-fc6c-4679-8246-d288f5690b17"
  ]
}
```

### Sending

[](#sending)

In order to send notifications you first need to initialize a `$coarNotificationInbox` object. This is because outbound notifications are saved to the same database table as described above.

Before creating an `OutboundNotification` object the necessary parts are created in isolation:

```
// This represents the entity sending the notification
$actor = new COARNotificationActor("actorId", "actorName", "Person");

// The journal that the actor wishes to publish in
$object = new COARNotificationObject("https://overlay-journal.com/reviews/000001/00001",
"https://doi.org/10.3214/987654", array("Document", "sorg:Review"));

// The url of the context object, see below
$url = new COARNotificationURL("https://research-organisation.org/repository/preprint/201203/421/content.pdf",
"application/pdf", array("Article", "sorg:ScholarlyArticle"));

// The actual content that is to be actioned on
$context = new COARNotificationContext("https://research-organisation.org/repository/preprint/201203/421/",
"https://doi.org/10.5555/12345680", array("sorg:AboutPage"), $url);

// This represents the target system the notification is to be delivered to
$target = new COARNotificationTarget("https://research-organisation.org/repository",
"http://localhost:81/post");

// Create the notification
$notification = $coarNotificationManager->createOutboundNotification($actor, $object, $context, $target);
```

Put together, these POPOs constitute an almost fully formed COAR Notification, only thing left is to call one of the following:

```
$coarNotificationManager->announceEndorsement($notification);
```

or

```
$coarNotificationManager->announceReview($notification);
```

or :

```
$notification->requestReview($notification);
```

Note that all of the patterns have the optional `$inReplyTo` parameter to indicate that the step is in response to an earlier step.

Development
-----------

[](#development)

A `docker-compose.yml` is including to make experimentation and development easy. It connects an Apache HTTPD2 container with a MySQL container. Just run:

`$ docker-compose up`

At `http://localhost:8060/` there is an interactive form you can use to semi-manually create a COAR Notification. Note that three fields; `type`, `url type` and `object type` expect comma separated values that will be split into an array of strings.

At `http://localhost:8060/inbox.php` notifications sent or received will be listed by id and timestamp.

### Unit testing

[](#unit-testing)

This project uses [PHPUnit](https://phpunit.de/) for unit testing. In order to run the tests bring up the docker containers with `docker compose up -d` and then run `docker exec coar_notify_php ./vendor/bin/phpunit tests`.

License
-------

[](#license)

Copyright © 2021

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Funding
-------

[](#funding)

Project funded with support from the [French National Fund for Open Science](https://www.ouvrirlascience.fr/national-fund-for-open-science/)

Projet financé avec le soutien du [Fonds National pour la Science Ouverte](https://www.ouvrirlascience.fr/national-fund-for-open-science/)

Appendix
--------

[](#appendix)

Example of a COAR Notification JSON payload:

```
{
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    "https://purl.org/coar/notify"
  ],
  "actor": {
    "id": "https://overlay-journal.com",
    "name": "Overlay Journal",
    "type": "Service"
  },
  "context": {
    "id": "https://research-organisation.org/repository/preprint/201203/421/",
    "ietf:cite-as": "https://doi.org/10.5555/12345680",
    "type": "sorg:AboutPage",
    "url": {
      "id": "https://research-organisation.org/repository/preprint/201203/421/content.pdf",
      "media-type": "application/pdf",
      "type": [
        "Article",
        "sorg:ScholarlyArticle"
      ]
    }
  },
  "id": "urn:uuid:94ecae35-dcfd-4182-8550-22c7164fe23f",
  "object": {
    "id": "https://overlay-journal.com/reviews/000001/00001",
    "ietf:cite-as": "https://doi.org/10.3214/987654",
    "type": [
      "Document",
      "sorg:Review"
    ]
  },
  "origin": {
    "id": "https://overlay-journal.com/system",
    "inbox": "https://overlay-journal.com/system/inbox/",
    "type": "Service"
  },
  "target": {
    "id": "https://research-organisation.org/repository",
    "inbox": "https://research-organisation.org/repository/inbox/",
    "type": "Service"
  },
  "type": [
    "Announce",
    "coar-notify:ReviewAction"
  ]
}
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.7% 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 ~70 days

Recently: every ~139 days

Total

9

Last Release

1109d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8e385ad1b1dfcd3e04a78ad2a58fdc199421b11cd5fdde133b81520f7c34b261?d=identicon)[richard-jones](/maintainers/richard-jones)

![](https://www.gravatar.com/avatar/1c212a5ee3292bcabc6280e7ba132049867f30a18c564a17ceb5c254f0468c62?d=identicon)[jabbi](/maintainers/jabbi)

---

Top Contributors

[![J4bbi](https://avatars.githubusercontent.com/u/5488106?v=4)](https://github.com/J4bbi "J4bbi (76 commits)")[![rtournoy](https://avatars.githubusercontent.com/u/3829967?v=4)](https://github.com/rtournoy "rtournoy (5 commits)")[![richard-jones](https://avatars.githubusercontent.com/u/856138?v=4)](https://github.com/richard-jones "richard-jones (1 commits)")

---

Tags

publishingrepositoryLinked Dataopen accesspeer-review

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cottagelabs-coar-notifications/health.svg)

```
[![Health](https://phpackages.com/badges/cottagelabs-coar-notifications/health.svg)](https://phpackages.com/packages/cottagelabs-coar-notifications)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[oro/platform

Business Application Platform (BAP)

645143.5k115](/packages/oro-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M577](/packages/shopware-core)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M508](/packages/pimcore-pimcore)

PHPackages © 2026

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