sooluh/papercups

Unofficial Papercups PHP library provides convenient access to the Papercups API from applications written in server-side PHP

dev-main 2023-05-24 06:24 UTC

This package is auto-updated.

Last update: 2024-12-24 09:29:55 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

Unofficial Papercups PHP library provides convenient access to the Papercups API from applications written in server-side PHP.

Requirements

  • PHP >= 7.3
  • Composer

Features

  • PSR-4 autoloading compliant structure
  • PSR-2 compliant code style
  • Easy to use with any framework or even a plain php file
  • Useful tools for better code included

Installation

Install the package with:

composer require sooluh/papercups

Usage

The package needs to be configured with an API key, which is available in the Papercups dashboard. Require the package with the key's value:

<?php
// make sure composer dependencies have been installed
require __DIR__ . '/vendor/autoload.php';

$papercups = new \Papercups\Client('PAPERCUPS_API_KEY');

$response = $papercups->messages()->create([
    'body' => 'Hello world!',
    'conversation_id' => '...'
]);

print_r($response);

If you're self-hosting Papercups on a different server, you can specify the API host:

$papercups = new \Papercups\Client('PAPERCUPS_API_KEY', 'https://papercups.mycompany.co');

License

Code licensed under MIT License.