PHP wrapper to PagerDuty Events API.

2.1.0 2018-06-02 08:37 UTC


PHP implementation of the PagerDuty Events API

Important: v2 is a complete rewrite of the library. It is not backwards compatible with v1.

For all new projects i suggest using v2. It is more flexible and easier to use than v1, and overcomes some of its predecessor's design limitations.

Latest Stable Version Total Downloads

Features :

Installation :

Add this line to your project's composer.json

    "require": {
        "adilbaig/pagerduty": "2.*"

The packagist URL is


Trigger an event

use \PagerDuty\TriggerEvent;
use \PagerDuty\PagerDutyException;

$serviceKey = "1d334a4819fc4b67a795b1c54f9a"; //Replace this with the integration key of your service.

// In this example, we're triggering a "Service is down" message.
try {
    $responseCode = (new TriggerEvent($serviceKey, "Service is down"))->send();
    if($responseCode == 200)
        echo "Success";
    elseif($responseCode == 403)
        echo "Rate Limited";  //You're being throttled. Slow down.
} catch(PagerDutyException $exception) { //This doesn't happen unless you've broken their guidelines. The API tries to minimize user mistakes

Automatically send only one PagerDuty incident for repeated errors

//After this example, you will see just one incident on PD

(new TriggerEvent($serviceKey, "Service is down", true))->send();
(new TriggerEvent($serviceKey, "Service is down", true))->send();
(new TriggerEvent($serviceKey, "Service is down", true))->send();

Create a detailed 'trigger' event, add optional data. Dump the event and inspect response from PD

use \PagerDuty\TriggerEvent;
use \PagerDuty\Context\LinkContext;
use \PagerDuty\Context\ImageContext;

//Taken from the `trigger` example @

$event = new TriggerEvent($serviceKey, "FAILURE for production/HTTP on machine");
    ->setClient("Sample Monitoring Service")
    ->setDetails(["ping time" => "1500ms", "load avg" => 0.75])
    ->addContext(new LinkContext(""))
    ->addContext(new LinkContext("", "View the incident on PagerDuty"))
    ->addContext(new ImageContext(",2,9,5,2,5,7,4,8,2,1&cht=lc&chds=a&chxt=y&chm=D,0033FF,0,0,5,1"));

// Pass in the '$response' variable by reference if you want to inspect PD's response. This is optional, and you probably don't need this in production.
$response = null;
$responseCode = $event->send($response);

Acknowledge an event

(new AcknowledgeEvent($serviceKey, "incident key"))->send();

Resolve an event

(new ResolveEvent($serviceKey, "incident key"))->send();


Q. How do i get the service key from PagerDuty?

A. In your PagerDuty console, click 'Configuration' > 'Services'. Click the link under 'Integrations' column. It's the 'Integration Key'

Read more here :


This library needs the curl pecl extension.

In Ubuntu 16.04, install it like so :

sudo apt install php-curl