Skip to content

About

Framework-agnostic PHP client for the track.to API. Read-only split target — develop in expertsystemsau/trackto-php-sdk.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

46 Commits

Folders and files

Repository files navigation

track.to PHP client

Framework-agnostic PHP client for the track.to API. Requires PHP 8.2 or later.

This repository is a read-only split of expertsystemsau/trackto-php-sdk. Open issues and pull requests there, not here.

Compatibility

Version PHP Laravel track.to API (Track-Version)
1.x 8.2, 8.3, 8.4, 8.5 any (framework-agnostic) 2026-07-06

Install

composer require expertsystemsau/trackto-php-client

Quick start

Build the client with named arguments and make one call per resource:

use ExpertSystems\TrackTo\TrackToClient;

$client = new TrackToClient(apiKey: getenv('TRACKTO_API_KEY'));

$link = $client->links()->create(destinationUrl: 'https://example.com/landing', slug: 'launch');
echo $link->shortUrl;

$page = $client->links()->list(search: 'launch', perPage: 50);

foreach ($client->links()->all() as $link) {
    echo $link->slug;
}

$folder = $client->folders()->create(name: 'Campaigns');
$tag = $client->tags()->create(name: 'launch');

list() fetches one page. all() walks every page lazily.

Errors

Every exception the SDK throws implements TrackToException. API errors expose status(), errors() and rateLimit():

use ExpertSystems\TrackTo\Exceptions\RateLimitedException;
use ExpertSystems\TrackTo\Exceptions\TrackToException;

try {
    $client->links()->get('launch');
} catch (RateLimitedException $e) {
    sleep($e->rateLimit()->retryAfter ?? 1);
} catch (TrackToException $e) {
    error_log($e->getMessage());
}

Testing

withMockClient() returns a copy of the client wired to Saloon's MockClient. Fixtures builds response bodies that match the API spec:

use ExpertSystems\TrackTo\Testing\Fixtures;
use Saloon\Http\Faking\MockClient;
use Saloon\Http\Faking\MockResponse;

$client = $client->withMockClient(new MockClient([
    MockResponse::make(Fixtures::page([Fixtures::link()])),
]));

The full contract, including retries, pagination and update semantics, is in the conventions.

See the changelog for release history.

License

MIT. See LICENSE.md.

About

Framework-agnostic PHP client for the track.to API. Read-only split target — develop in expertsystemsau/trackto-php-sdk.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages