PHPackages                             staffbase/plugins-sdk-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. staffbase/plugins-sdk-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

staffbase/plugins-sdk-php
=========================

Staffbase PHP SDK library for plugins.

3.0.1(7mo ago)626.7k↓48.5%4[6 PRs](https://github.com/Staffbase/plugins-sdk-php/pulls)Apache-2.0PHPPHP ^8.3 || ^8.4CI passing

Since Mar 8Pushed 3mo ago26 watchersCompare

[ Source](https://github.com/Staffbase/plugins-sdk-php)[ Packagist](https://packagist.org/packages/staffbase/plugins-sdk-php)[ Docs](https://github.com/Staffbase/plugins-sdk-php)[ RSS](/packages/staffbase-plugins-sdk-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (34)Used By (0)

Plugin SDK for PHP
==================

[](#plugin-sdk-for-php)

[![Build Status](https://github.com/Staffbase/plugins-sdk-php/workflows/PHP%20Composer/badge.svg)](https://github.com/Staffbase/plugins-sdk-php/actions)[![License](https://camo.githubusercontent.com/a549a7a30bacba7bfceebdc207a8e86c3f2c02995a2527640dca30048fd2b64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d417061636865253230322e302d626c75652e737667)](https://opensource.org/licenses/Apache-2.0)

If you are developing your own plugin for your Staffbase app we describe the authentication flow of a plugin at . While this documentation just covers the conceptual ideas of the interface of plugins though – the so called Plugin SSO – we want to provide a library to help you develop your first plugin for Staffbase even faster. This SDK provides the basic functionality to parse and verify a provided token for PHP.

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

[](#installation)

We provide our Plugin SDK via Composer (). Thus, you can just use Composer for installation:

```
composer require staffbase/plugins-sdk-php

```

Dependencies
------------

[](#dependencies)

Dependencies are also managed by Composer. When using this repository keep the following dependencies in mind (cf. [composer.json](composer.json)):

- php: ^8.3
- lcobucci/jwt: ^5.5

API Reference
-------------

[](#api-reference)

For the API reference of this SDK please consult the [docs](doc/api.md).

Code Example
------------

[](#code-example)

You can try to create a token from the received jwt.

```
use Exception;
use Staffbase\plugins\sdk\SSOToken;

try {

	$appSecret = 'abcdef012345='; // the public key received from Staffbase.

	$sso = new SSOToken($appSecret, $_GET['jwt']);
	print "Hello again ". $sso->getFullName();

} catch (Exception $e) {

	print "Sorry we could not authenticate You.";
	exit;
}
```

To manage multiple instances easy and secure we provide a convenience class which abstracts the session. The `PluginSession` class has the same data interface as `SSOToken`. It also provides the means to set a custom session save handler as the optional third parameter of `__construct`. `PluginSession` will automatically take care of reading the URL parameters and saving the SSO info in the session for further requests after the Token gets invalid.

```
use Exception;
use Staffbase\plugins\sdk\PluginSession;

try {

	$pluginId  = 'weatherplugin'; // the id you received from Staffbase.
	$appSecret = 'abcdef012345='; // the public key received from Staffbase.

	$session = new PluginSession($pluginId, $appSecret);

	print "Hello again ". $PluginSession->getFullName(). ', '. $PluginSession->getSessionVar('message');

} catch (Exception $e) {

	print "Sorry we could not authenticate You.";
	exit;
}
```

### Remote calls

[](#remote-calls)

With the version 1.2.0 we introduced the concept of remote calls. These can happen if the Staffbase app need's to notify the plugin about an event which may be relevant. Events could be such as: a plugin instance gets deleted or a user should be logged out. For now we support only the instance-deletion call. You can find all supported calls in the `RemoteCall` namespace.

```
use Staffbase\plugins\sdk\RemoteCall\AbstractRemoteCallHandler;
use Staffbase\plugins\sdk\RemoteCall\DeleteInstanceCallHandlerInterface;

// create a call handler which can have multiple call interfaces implemented
class RemoteCallHandler extends AbstractRemoteCallHandler implements DeleteInstanceCallHandlerInterface {

    private $db;

    public function __construct($db) {

        $this->db = $db;
    }

    public function deleteInstance($instanceId) {

        $result = $this->db->posts->deleteByInstance($instanceId);

        return $result !== false;
    }
}

// pass it to the PluginSession on construction as the last parameter
$remoteCallHandler = new RemoteCallHandler($db);
$session = new PluginSession(PLUGIN_ID, $secret, $sessionHandler, null, $remoteCallHandler);

/* Unreachable code in a delete call follows */
...
```

Please notice that a remote call will either be exited through proper implementation of `RemoteCallInterface`'s exit functions or forcefully with a warning. This happens because practically there is no session to built after a call.

Contribution
------------

[](#contribution)

- Fork it
- Create a branch `git checkout -b feature-description`
- Put your name into authors.txt
- Commit your changes `git commit -am "Added ...."`
- Push to the branch `git push origin feature-description`
- Open a Pull Request

Running Tests
-------------

[](#running-tests)

To run the tests a simple `# composer test` command in the root directory will suffice. Please consult [composer.json](composer.json) to learn which phpunit version is currently in use.

License
-------

[](#license)

Copyright 2017-2025 Staffbase GmbH.

Licensed under the Apache License, Version 2.0:

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance72

Regular maintenance activity

Popularity33

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity92

Battle-tested with a long release history

 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 ~184 days

Recently: every ~267 days

Total

18

Last Release

224d ago

Major Versions

1.5.4 → 2.0.02021-04-20

2.1.2 → 3.0.02025-05-22

PHP version history (6 changes)1.0.0-rc1PHP &gt;=5.5.9

1.5.0PHP ^7.3

2.0.0PHP ^7.4

2.1.1PHP ^7.4 || ^8.0

3.0.0PHP ~8.3.0

3.0.1PHP ^8.3 || ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/bb3ae5e345de57284f583dfa1ee877ab24f4ebb5ee3d735dfb90806745e62c51?d=identicon)[staffbase](/maintainers/staffbase)

![](https://www.gravatar.com/avatar/bebe89e4abff480b3cfea0c5ae98a26259146cb5f0bb41509247ad337822436a?d=identicon)[telomir](/maintainers/telomir)

---

Top Contributors

[![Ninerian](https://avatars.githubusercontent.com/u/117885?v=4)](https://github.com/Ninerian "Ninerian (76 commits)")[![viviivanov](https://avatars.githubusercontent.com/u/26089267?v=4)](https://github.com/viviivanov "viviivanov (43 commits)")[![cornelius-behrend](https://avatars.githubusercontent.com/u/77003328?v=4)](https://github.com/cornelius-behrend "cornelius-behrend (19 commits)")[![m-seidel](https://avatars.githubusercontent.com/u/47413751?v=4)](https://github.com/m-seidel "m-seidel (17 commits)")[![staust](https://avatars.githubusercontent.com/u/28901187?v=4)](https://github.com/staust "staust (6 commits)")[![FenziRocks](https://avatars.githubusercontent.com/u/45943789?v=4)](https://github.com/FenziRocks "FenziRocks (4 commits)")[![axdotl](https://avatars.githubusercontent.com/u/9337156?v=4)](https://github.com/axdotl "axdotl (3 commits)")[![timdittler](https://avatars.githubusercontent.com/u/93928360?v=4)](https://github.com/timdittler "timdittler (2 commits)")[![Thurisas](https://avatars.githubusercontent.com/u/6530461?v=4)](https://github.com/Thurisas "Thurisas (1 commits)")[![tr3ddy](https://avatars.githubusercontent.com/u/2187636?v=4)](https://github.com/tr3ddy "tr3ddy (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

need-for-speedpluginphpsdklibrarypluginsstaffbase

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/staffbase-plugins-sdk-php/health.svg)

```
[![Health](https://phpackages.com/badges/staffbase-plugins-sdk-php/health.svg)](https://phpackages.com/packages/staffbase-plugins-sdk-php)
```

PHPackages © 2026

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