Download the PHP package vaslv/brevity-php-sdk without Composer
On this page you can find all versions of the php package vaslv/brevity-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vaslv/brevity-php-sdk
More information about vaslv/brevity-php-sdk
Files in vaslv/brevity-php-sdk
Package brevity-php-sdk
Short Description PHP SDK for Brevity short links API
License MIT
Informations about the package brevity-php-sdk
Brevity PHP SDK
PHP client for the Brevity short-link engine API.
Русская версия: README.ru.md
Features
- Full
/api/v1surface: create links (POST /links), read link state with a click summary (GET /links/{code}), partial updates (PATCH /links/{code}), domain and domain-group registries. - Typed request/response DTOs: rules with up to 10 AND-ed conditions, A/B split
variants with weights, activity window (
valid_since/valid_until) and click budget (max_clicks). - RFC 7807 error handling: exceptions are dispatched on the stable problem
typecode, never on texts or bare HTTP statuses. - Contract-recommended transport behavior: retries only for network failures
and 5xx,
Accept: application/jsoneverywhere, obvious mistakes rejected client-side before any HTTP round trip. - Laravel bridge (5.8+): auto-discovered service provider, facade and publishable config.
- Runs on PHP 7.1+ with Guzzle 6.5 or 7.
Requirements
- PHP >= 7.1 with
ext-json guzzlehttp/guzzle^6.5 || ^7.0- optional: Laravel 5.8+ for the bridge
Installation
Quick start
The API is served only on the technical host (the one behind APP_URL);
short-link domains answer 404 to any /api/... request. The token is issued
from the admin panel and must carry the links:create ability — newly issued
tokens also get links:read and links:update.
Usage
Conditions and A/B variants
Condition types: time_before, after_date, query_param, ip_address,
device, language — see API.md (§6) for the data shape of
each. Condition data passes through the SDK untouched.
Activity window and click budget
Outside the window, or once the budget is exhausted, the link answers 404.
Domain selection
Reading a link
Updating a link
Untouched fields keep their server-side values; setRules() replaces the
whole rule list. code and domain cannot be changed.
Error handling
Every /api/v1 error is an RFC 7807 problem; the SDK dispatches on the stable
type code:
type |
HTTP | Exception |
|---|---|---|
unauthenticated |
401 | AuthenticationException |
missing-ability |
403 | MissingAbilityException |
forbidden |
403 | ForbiddenException |
not-found |
404 | NotFoundException |
validation-error |
422 | ValidationException (getErrors()) |
too-many-requests |
429 | RateLimitException (getRetryAfter()) |
http-error, server-error |
other | ApiException |
An unknown type (a proxy answering instead of the API, a future contract
code) falls back to the HTTP-status mapping; the raw code stays available
via getProblemType().
All of the above extend ApiException (getStatusCode(), getResponseBody(),
getProblemType()); MissingAbilityException extends ForbiddenException.
Network/timeout failures throw TransportException; client-side misuse
(contradictory options, an empty patch) throws InvalidRequestException
before any HTTP round trip.
Rate limits: two independent budgets — reads and writes — of 120 requests per minute per service.
Laravel
The service provider and the Brevity facade are auto-discovered on
Laravel 5.8+. Configure via .env:
Publish the config when you need to tweak it:
php artisan vendor:publish --tag=brevity-config.
Testing
No local PHP toolchain needed — the suite runs in Docker:
Documentation
The full API contract lives in API.md — a copy of the canonical
English docs/03-api.md of the main repository,
where a Russian mirror is kept under docs/ru/.
License
MIT