Sending Notifications with PHP

Updated on March 29, 2026

Learn how to send Signalgrid notifications from PHP applications using the official Composer package

Signalgrid provides an official PHP library that makes it easy to send notifications from any PHP application.

The library is available via Composer and works with:

  • Web applications
  • Backend services
  • Scripts
  • Cron jobs
  • Automation tools

Repository: https://github.com/signalgridco/signalgrid-php


Installation

Install the package using Composer:

composer require signalgrid/signalgrid-php

Composer will automatically download the library and make it available through the autoloader.


Basic Usage

To send a notification, create a Signalgrid client and call send().

<?php

require 'vendor/autoload.php';

use Signalgrid\Client;

$signalgrid = new Client("YOUR_CLIENT_KEY");

$signalgrid->send([
    "channel" => "YOUR_CHANNEL_TOKEN",
    "title"   => "Server Alert",
    "body"    => "Database connection lost",
    "type"    => "CRIT",
    "critical"=> true
]);

Parameters

Parameter
Description
channel
Channel token that receives the notification.
title
Notification title.
body
Notification message.
type
Notification type (INFO, WARN, CRIT, SUCCESS).
critical
Sends the notification as a critical alert.

Example: Simple Notification Script

The following example sends a notification when a script finishes.

<?php

require 'vendor/autoload.php';

use Signalgrid\Client;

$signalgrid = new Client("YOUR_CLIENT_KEY");

$signalgrid->send([
    "channel" => "YOUR_CHANNEL_TOKEN",
    "title"   => "Backup Completed",
    "body"    => "Nightly backup finished successfully",
    "type"    => "SUCCESS"
]);

This is useful for:

  • cron jobs
  • deployment scripts
  • CI/CD pipelines
  • maintenance tasks

Example: Sending a Critical Notification

<?php

require 'vendor/autoload.php';

use Signalgrid\Client;

$signalgrid = new Client("YOUR_CLIENT_KEY");

$signalgrid->send([
    "channel" => "YOUR_CHANNEL_TOKEN",
    "title"   => "Server Down",
    "body"    => "The web server stopped responding",
    "type"    => "CRIT",
    "critical"=> true
]);

This sends a critical alert that bypasses Do Not Disturb on supported devices.


Using Environment Variables (Recommended)

Avoid hardcoding your client key, use environment variables instead:

$signalgrid = new Client(getenv("SIGNALGRID_CLIENT_KEY"));

Example .env:

SIGNALGRID_CLIENT_KEY=abc123

Related Documentation