Unofficial Papercups PHP library provides convenient access to the Papercups API from applications written in server-side PHP.
- PHP >= 7.3
- Composer
- 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
Install the package with:
composer require sooluh/papercups
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');
Code licensed under MIT License.