utopia-php/fastly

Fastly HTTP API client built on utopia-php/client

Maintainers

👁 loks0n

Package info

github.com/utopia-php/fastly

pkg:composer/utopia-php/fastly

Statistics

Installs: 1 039

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.1 2026-06-26 10:48 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT a693a270e03780a4651d13fe146a1c33423b5c73

phphttpcdnfastlypurgeutopia

This package is auto-updated.

Last update: 2026-06-26 10:52:01 UTC


README

Important

This repository is a read-only mirror of the utopia-php monorepo. Development happens in packages/fastly — please open issues and pull requests there.

A small Fastly API client for PHP 8.4+, built on utopia-php/client. It currently exposes surrogate-key purging.

Install

composer require utopia-php/fastly

Usage

<?php

use Utopia\Client;
use Utopia\Client\Adapter\Curl\Client as CurlAdapter;
use Utopia\Fastly\Fastly;

require __DIR__ . '/vendor/autoload.php';

$fastly = new Fastly(
 new Client(new CurlAdapter()), // any PSR-18 client
 serviceId: 'SU1Z0isxPaozGVKXdv0eY',
 token: 'your-fastly-api-token',
);

// Invalidate every response tagged with this surrogate key.
$fastly->purge('homepage');

purge() issues POST {endpoint}/{serviceId}/purge/{surrogateKey} with the API token in the Fastly-Key header. A non-2xx response raises Utopia\Fastly\Exception\PurgeException; network failures surface as the underlying PSR-18 client exceptions.

The endpoint (https://api.fastly.com/service) and token header (Fastly-Key) are constructor arguments, so the client also works against a compatible proxy:

$fastly = new Fastly($client, $serviceId, $token, 'https://cdn.internal/service', 'X-Purge-Key');