Skip to content

PHP SDK

pliic/pliic-php is the official PHP SDK. It is for integrating Pliic natively in your backend: instead of embedding the widget, your system creates suggestions and tickets on behalf of your users, renders the board with vote state, replies to tickets, and consumes webhooks, all through the REST API.

If the embedded widget already covers your needs, you don’t need the SDK. Reach for it when you want full control of the experience inside your product.

Terminal window
composer require pliic/pliic-php

Requires PHP 8.2+ with ext-curl and ext-json. No other dependencies.

Create the client with your app’s secret key (sk_live_..., from the app settings tab):

use Pliic\PliicClient;
$pliic = new PliicClient('sk_live_...');

Endpoints require scopes on the key (suggestions:read, suggestions:write, tickets:read, tickets:write, and so on) and the API feature available on your plan.

Every write accepts a user object with the identity of the user in your system. Pliic creates or reuses the matching user automatically (same email means same person):

$user = ['id' => 'u_123', 'name' => 'Ana', 'email' => '[email protected]'];
$pliic->suggestions->create([
'user' => $user,
'title' => 'Dark mode',
'description' => 'Easier on the eyes at night.',
]);

You never need Pliic’s internal id: the id is the one from your own database.

// Board with the current user's vote state
$pliic->suggestions->list(['status' => 'planned', 'search' => 'dark', 'user_id' => 'u_123']);
$pliic->suggestions->get(42, ['user_id' => 'u_123']); // includes user_has_voted
$pliic->suggestions->vote(42, ['user' => $user]); // votes; calling again undoes it
$pliic->suggestions->comments(42);
$pliic->suggestions->addComment(42, ['user' => $user, 'body' => 'Great idea!']);
$pliic->tickets->list(['user_id' => 'u_123']); // that user's tickets
$pliic->tickets->create(['user' => $user, 'subject' => 'Checkout error', 'body' => '...', 'type' => 'bug']);
$pliic->tickets->get(7); // includes the full public thread
$pliic->tickets->reply(7, ['user' => $user, 'body' => 'More detail here...']);

Only the ticket author can reply through it, and your team’s internal notes never appear in the returned thread.

If you also embed the widget, mint the userToken server-side with the SDK:

use Pliic\UserToken;
$token = UserToken::mint($secretKey, [
'id' => 'u_123',
'name' => 'Ana',
'email' => '[email protected]',
]);

Hand $token to your frontend as the widget’s userToken.

Verify the signature before trusting any payload:

use Pliic\Webhook;
use Pliic\Exceptions\SignatureVerificationException;
try {
$event = Webhook::constructEvent(
$request->getContent(),
$request->header('X-Pliic-Signature'),
$endpointSecret, // whsec_...
);
} catch (SignatureVerificationException $e) {
abort(400);
}
match ($event->type) {
'suggestion.created' => handleSuggestion($event->data),
'ticket.created' => handleTicket($event->data),
default => null,
};

Signature format details and available events: Webhooks.

API failures become typed exceptions, all extending Pliic\Exceptions\ApiErrorException:

StatusException
401AuthenticationException
403PermissionException (missing scope or plan feature)
404NotFoundException
422ValidationException ($e->errors() has the per-field errors)
429RateLimitException

Network-level failures become Pliic\Exceptions\TransportException.

To build the interface in the browser (instead of the backend), use @pliic/sdk, which talks to the widget API using the public key.