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.
Install
Section titled “Install”composer require pliic/pliic-phpRequires PHP 8.2+ with ext-curl and ext-json. No other dependencies.
Authentication
Section titled “Authentication”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.
Acting on behalf of your user
Section titled “Acting on behalf of your user”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):
$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.
Suggestions
Section titled “Suggestions”// 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!']);Tickets
Section titled “Tickets”$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.
Widget token (SSO)
Section titled “Widget token (SSO)”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',]);Hand $token to your frontend as the widget’s userToken.
Webhooks
Section titled “Webhooks”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.
Errors
Section titled “Errors”API failures become typed exceptions, all extending Pliic\Exceptions\ApiErrorException:
| Status | Exception |
|---|---|
| 401 | AuthenticationException |
| 403 | PermissionException (missing scope or plan feature) |
| 404 | NotFoundException |
| 422 | ValidationException ($e->errors() has the per-field errors) |
| 429 | RateLimitException |
Network-level failures become Pliic\Exceptions\TransportException.
Building the UI in JavaScript?
Section titled “Building the UI in JavaScript?”To build the interface in the browser (instead of the backend), use @pliic/sdk, which talks to the widget API using the public key.