Search by

trustcomponent / trustcomponent-php

trustcomponent

Official TrustComponent SDK for PHP: TrustCaptcha, TrustAnalytics, TrustMonitoring, Trust VAT Checker and the platform API.

Package info

github.com/trustcomponent/trustcomponent-php

Homepage

pkg:composer/trustcomponent/trustcomponent-php

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 0

v0.0.1-beta.1 2026-11-26 23:52 UTC

This package is not auto-updated.

Last update: 2026-11-27 00:13:17 UTC


README

The official SDK for the TrustComponent API: TrustCaptcha, TrustAnalytics, TrustMonitoring, Trust VAT Checker and the platform API, in one package. Developed and hosted in the EU.

Requires PHP 8.1 or newer.

Install

composer require trustcomponent/trustcomponent-php

Check a TrustCaptcha result

The widget writes a verification token into your form. One call turns it into the result:

$tc = new TrustComponent\TrustComponent('ak_…');
$result = $tc->captcha()->getVerificationResult($_POST['tc-verification-token']);
if ($result->getVerificationPassed()) { /* … */ }

Create the API key (ak_…) in the dashboard under the project's API keys. The key decides which modules the client can use.

Every module

The client is module → resource → operation, with the same names in every language:

$tc->analytics()->websites()->getWebsites();
$tc->taxValidation()->validations()->createValidation(new TaxValidationValidationCreateParams(['countryCode' => 'DE', 'rawValue' => 'DE811569869']));
$tc->monitoring()->heartbeats()->pingHeartbeat($serviceId, $monitorId);
$tc->platform()->events()->getEvents();

The full reference of every operation is at https://docs.trustcomponent.com.

Configuration

$tc = TrustComponent\TrustComponent::builder('ak_…')
    ->timeout(5)->maxRetries(1)->integration('my-plugin/1.0')
    ->build();

Options: host, connectTimeout, timeout, proxy, maxRetries, deprecationWarnings, integration, logger (PSR-3), handler (Guzzle).

The SDK retries only what the API reserves for retries: 429 with Retry-After, 502, 503, 504 and a lost connection (2 retries by default). When the API marks an operation as deprecated, it logs one warning per operation. Every request names the SDK in User-Agent and TrustComponent-Sdk, together with the integration you set.

Errors

Every error is a TrustComponent\Exception\TrustComponentException carrying the HTTP status and the stable code of the API: InvalidRequestException, AuthenticationException, PermissionException, PlanLimitException, NotFoundException, ConflictException, GoneException, RateLimitException, ServerException, ConnectionException, OperationRetiredException, VerificationTokenInvalidException.

try {
    $tc->captcha()->getVerificationResult($token);
} catch (TrustComponent\Exception\NotFoundException $e) {
    // $e->getCode() is the HTTP status, $e->errorCode the stable reason of the API
}

OperationRetired means the operation was switched off after its sunset: update the SDK.

Support

The GitHub repository of this SDK is a read-only mirror, generated from the TrustComponent API, so pull requests and issues are not processed there. For questions and bug reports, write to mail@trustcomponent.com or contact support through https://www.trustcomponent.com.

License

MIT