PHPackages                             knocklabs/knock-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. knocklabs/knock-php

ActiveLibrary[API Development](/categories/api)

knocklabs/knock-php
===================

Knock PHP SDK

v0.2.0(1y ago)7174.7k↓48.1%[1 issues](https://github.com/knocklabs/knock-php/issues)MITPHPPHP ^8.0CI passing

Since May 27Pushed 1y ago9 watchersCompare

[ Source](https://github.com/knocklabs/knock-php)[ Packagist](https://packagist.org/packages/knocklabs/knock-php)[ RSS](/packages/knocklabs-knock-php/feed)WikiDiscussions main Synced yesterday

READMEChangelog (10)Dependencies (15)Versions (19)Used By (0)

Knock PHP library
=================

[](#knock-php-library)

Documentation
-------------

[](#documentation)

See the [documentation](https://docs.knock.app) for PHP usage examples.

Installation
------------

[](#installation)

```
composer require knocklabs/knock-php php-http/guzzle7-adapter
```

Configuration
-------------

[](#configuration)

To use the library you must provide a secret API key, provided in the Knock dashboard.

```
use Knock\KnockSdk\Client;

$client = new Client('sk_12345');
```

Usage
-----

[](#usage)

### Identifying users

[](#identifying-users)

```
$client->users()->identify('jhammond', [
    'name' => 'John Hammond',
    'email' => 'jhammond@ingen.net',
]);
```

### Sending notifies (triggering workflows)

[](#sending-notifies-triggering-workflows)

```
$client->workflows()->trigger('dinosaurs-loose', [
    // user id of who performed the action
    'actor' => 'dnedry',
    // list of user ids for who should receive the notification
    'recipients' => ['jhammond', 'agrant', 'imalcolm', 'esattler'],
    // data payload to send through
    'data' => [
        'type' => 'trex',
        'priority' => 1,
    ],
    // an optional identifier for the tenant that the notifications belong to
    'tenant' => 'jurassic-park',
    // an optional key to provide to cancel a notify
    'cancellation_key' => '21e958bb-2517-40bb-aaaa-d40acc26dac3',
]);
```

### Retrieving users

[](#retrieving-users)

```
$client->users()->get('jhammond');
```

### Deleting users

[](#deleting-users)

```
$client->users()->delete('jhammond');
```

### Preferences

[](#preferences)

```
$client->users()->setPreferences('jhammond', [
    'channel_types' => [
        'email' => true,
        'sms' => false,
    ],
    'workflows' => [
        'dinosaurs-loose' => [
            'email' => false,
            'in_app_feed': true,
        ]
    ]
]);
```

### Getting and setting channel data

[](#getting-and-setting-channel-data)

```
$knock->users()->setChannelData('jhammond', '5a88728a-3ecb-400d-ba6f-9c0956ab252f', [
    'tokens' => [
        $apnsToken
    ],
});

$knock->users()->getChannelData('jhammond', '5a88728a-3ecb-400d-ba6f-9c0956ab252f');
```

### Canceling workflows

[](#canceling-workflows)

```
$client->workflows()->cancel('dinosaurs-loose', [
    'cancellation_key' => '21e958bb-2517-40bb-aaaa-d40acc26dac3'
    // optionally you can specify recipients here
    'recipients' => ['jhammond'],
]);
```

### Signing JWTs

[](#signing-jwts)

You can use the `firebase/php-jwt` package to [sign JWTs easily](https://github.com/firebase/php-jwt). You will need to generate an environment specific signing key, which you can find in the Knock dashboard.

If you're using a signing token you will need to pass this to your client to perform authentication. You can read more about [client-side authentication here](https://docs.knock.app/client-integration/authenticating-users).

```
use Firebase\JWT\JWT;

$privateKey = env('KNOCK_SIGNING_KEY');
$encoded = JWT::encode(['sub' => 'jhammond'], $privateKey, 'RS256');
```

Test
----

[](#test)

To run tests, first run `composer` in the terminal. Once compiled, you can run `phpunit tests/` to run the suite.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance42

Moderate activity, may be stable

Popularity39

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~102 days

Recently: every ~176 days

Total

11

Last Release

478d ago

PHP version history (2 changes)v0.1.0PHP ^7.4 || ^8.0

v0.2.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4e7263b19b5dd144e096952896ea61594f6462515d387d591f7649febd190c6c?d=identicon)[knocklabs](/maintainers/knocklabs)

---

Top Contributors

[![nthndnn](https://avatars.githubusercontent.com/u/1976300?v=4)](https://github.com/nthndnn "nthndnn (16 commits)")[![juanazam](https://avatars.githubusercontent.com/u/982261?v=4)](https://github.com/juanazam "juanazam (9 commits)")[![cjbell](https://avatars.githubusercontent.com/u/822528?v=4)](https://github.com/cjbell "cjbell (4 commits)")[![JEverhart383](https://avatars.githubusercontent.com/u/7818951?v=4)](https://github.com/JEverhart383 "JEverhart383 (2 commits)")[![brentjanderson](https://avatars.githubusercontent.com/u/45031?v=4)](https://github.com/brentjanderson "brentjanderson (2 commits)")[![meryldakin](https://avatars.githubusercontent.com/u/24256463?v=4)](https://github.com/meryldakin "meryldakin (2 commits)")[![connorlindsey](https://avatars.githubusercontent.com/u/12838032?v=4)](https://github.com/connorlindsey "connorlindsey (1 commits)")[![bceskavich](https://avatars.githubusercontent.com/u/5049830?v=4)](https://github.com/bceskavich "bceskavich (1 commits)")

---

Tags

knockphp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/knocklabs-knock-php/health.svg)

```
[![Health](https://phpackages.com/badges/knocklabs-knock-php/health.svg)](https://phpackages.com/packages/knocklabs-knock-php)
```

###  Alternatives

[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k28.0M318](/packages/openai-php-client)[brd6/notion-sdk-php

Notion SDK for PHP

6123.0k](/packages/brd6-notion-sdk-php)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M738](/packages/sylius-sylius)[getbrevo/brevo-php

Official Brevo provided RESTFul API V3 php library

1003.9M50](/packages/getbrevo-brevo-php)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28150.5k](/packages/phpro-http-tools)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
