Download the PHP package cottagelabs/coar-notifications without Composer

On this page you can find all versions of the php package cottagelabs/coar-notifications. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package coar-notifications

COAR Notification Manager

The COAR Notification (CNs) Manager can both act as an inbox that receives notification as well as send notifications. CNs are Linked Data Notifications that have a Activity Streams 2.0 like structure (see Appendix for an example of a COAR Notification).

CNs do not have a final specification, but notification patterns, further exemplified in example scenarios give good guidance.

It is written in PHP 7.4 with Guzzle (wrapped around cURL) and JSON. It uses Doctrine for persistence in a database, Monolog for logging, 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:

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 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

This module does not address the discovery part of the LDN recommendation. That is up to the developer of the web application.

A few configuration parameters can be passed to COARNotificationManager:

Variable Description Default value
conn either DBAL connnection parameters in an array or an already established DBAL Connection
logger A Monolog logger object NULL (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 seconds 5
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:

A table named notifications is assumed to have been created (see Installation & setup above). This table will contain all notifications using a 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

As per the LDN recommendation, 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:

Post

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

Example:

Get

As per the LDN recommendation, this method lists the inbox's contents. There is no pagination method available via the COAR Notification Manager. However Doctrine supports pagination.

Example:

Example output:

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:

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

or

or :

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

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

This project uses PHPUnit 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

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

Project funded with support from the French National Fund for Open Science

Projet financé avec le soutien du Fonds National pour la Science Ouverte

Appendix

Example of a COAR Notification JSON payload:


All versions of coar-notifications with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
doctrine/orm Version ^2.14.1
monolog/monolog Version ^1.26
symfony/cache Version ^5.3
ext-pdo Version *
ext-json Version *
ramsey/uuid Version ^4.2
ext-curl Version *
doctrine/annotations Version ^1.13
guzzlehttp/guzzle Version ^7.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package cottagelabs/coar-notifications contains the following files

Loading the files please wait ....