PHP SDK

Bring Snapshot Site into Laravel, Symfony, WordPress, and PHP backends

Use the official PHP SDK when your product already runs on PHP and you want screenshot, analyze, and compare workflows to feel native inside your backend codebase.

snapshot-site/php-sdk
Official package
PHP
Framework and backend friendly
Download helper
Save returned assets locally
Install:composer require snapshot-site/php-sdk
Auth:SNAPSHOT_SITE_API_KEY=ss_live_xxx
Get started for free
PHP workflow
PHP backend using a screenshot API to capture a webpage and download the returned image asset
Good fits
Laravel and Symfony applications that need browser-based capture workflows
WordPress and PHP services that need screenshot, analyze, and compare
Backend teams that want a simpler client than raw cURL requests
Projects that need to download returned assets locally

SDK overview

The PHP SDK gives backend teams a direct integration path into Snapshot Site without building custom request wrappers for each endpoint.

1

Built for existing PHP stacks

Use it inside Laravel, Symfony, WordPress, or custom PHP services.

2

One client for core workflows

Screenshot, analyze, and compare are available through the same SDK surface.

3

Works well in backend jobs

Use it in queues, backend services, export jobs, and internal tools.

4

Asset download helper included

Save returned assets locally without writing your own download logic.

Quick start

Install, authenticate, call the SDK

1

Install `snapshot-site/php-sdk` with Composer

2

Provide your Snapshot Site API key

3

Instantiate the client

4

Call screenshot, analyze, compare, or download helpers

Code examples

Screenshot

Minimal screenshot example

Capture a page from a PHP backend with a direct client.

<?php

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

use SnapshotSite\Client;

$client = new Client(getenv('SNAPSHOT_SITE_API_KEY'));

$result = $client->screenshot([
    'url' => 'https://snapshot-site.com/pricing',
    'width' => 1440,
    'format' => 'png',
    'fullSize' => true,
    'hideCookie' => true,
]);

echo $result['link'] ?? '';
Analyze

Analyze example

Run page analysis from the same PHP client.

$result = $client->analyze([
    'url' => 'https://snapshot-site.com',
    'width' => 1440,
    'fullSize' => true,
    'enableSummary' => true,
    'enableQuality' => true,
]);

print_r($result);
Compare

Compare and save assets

Compare two states and download the returned asset locally.

$result = $client->compare([
    'before' => [
        'url' => 'https://snapshot-site.com/pricing',
        'width' => 1440,
        'fullSize' => true,
        'hideCookie' => true,
    ],
    'after' => [
        'url' => 'https://staging.snapshot-site.com/pricing',
        'width' => 1440,
        'fullSize' => true,
        'hideCookie' => true,
    ],
    'threshold' => 0.1,
]);

$client->downloadTo($result, __DIR__ . '/pricing.png');

PHP screenshot API integration

The official snapshot-site/php-sdk package gives PHP applications one client for website screenshots, AI-assisted page analysis, visual comparison, and asset download. It works as a regular Composer dependency rather than a framework-specific bundle, so Laravel, Symfony, WordPress, and custom services can place it where outbound API clients belong in their architecture.

The current package requires PHP 8.1 or later with the cURL and JSON extensions. The client defaults to the production Snapshot Site API unless a different base URL is explicitly provided.

Install and configure the PHP client

Install the package with Composer, then read the API key from server-side configuration.

<?php

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

use SnapshotSite\Client;

$apiKey = getenv('SNAPSHOT_SITE_API_KEY');

if (!$apiKey) {
    throw new RuntimeException('SNAPSHOT_SITE_API_KEY is not configured');
}

$snapshotSite = new Client($apiKey);

Do not place the key in a public repository, rendered template, frontend script, or WordPress option that unauthenticated users can read. In a framework, load it through the normal secrets or environment configuration and inject the client into the server-side service that needs it.

Choose the PHP method by task

Capture with screenshot()

Use screenshot() for PNG, JPEG, WebP, or PDF output. Make width explicit, enable fullSize only when the complete document is required, and add a deliberate delay when dynamic content needs time to settle. The full-page screenshot guide explains the long-page tradeoffs.

Analyze with analyze()

Use analyze() when the rendered page should also return summary or quality information. Enable only the analysis options the application consumes, and preserve the screenshot when a reviewer may need to verify the generated result.

Compare with compare()

Use compare() for staging-versus-production checks, stored baselines, and other visual regression workflows. Both sources should use identical width, full-page, delay, and cleanup options. Inspect the diff image rather than treating mismatch percentage as a complete pass/fail decision.

Save an asset with downloadTo()

downloadTo() accepts a direct URL or supported response structure. It can extract a screenshot link, an analyze screenshot link, or the diff link from a comparison response and write the binary to the path supplied by the application.

Choose the path intentionally. Validate filenames, create directories with appropriate permissions, and avoid writing user-controlled paths without normalization.

Laravel and Symfony patterns

In Laravel, place the client behind an application service and run recurring or batch captures from queued jobs or console commands. In Symfony, register the client or a small wrapper as a service and keep request construction in the domain or application layer that owns the workflow.

The goal is the same in both frameworks: keep API credentials and transport logic out of controllers and templates. A controller can request a capture job; a service or worker can perform it, store the result, and report a domain-level outcome.

When the user does not need the image immediately, a queue prevents browser-rendering latency from holding open the original web request. Record success or failure per job and apply bounded retries only to transient conditions.

WordPress integration considerations

Use the SDK from plugin or server-side application code, not from theme JavaScript. Schedule background work through the mechanism appropriate to the site and avoid initiating a fresh capture on every public page view.

If administrators can submit URLs, check capabilities and nonces according to the WordPress workflow, validate the URL, and restrict target domains when the feature is intended for a known site set. Store only the response data and files the plugin needs.

Batch capture and error handling

For many URLs, process a bounded number at a time. Save progress per URL so a later failure does not discard earlier results. Log a sanitized target and internal job identifier, never the API key or a URL containing private tokens.

Separate permanent input problems from transient transport failures. An invalid URL, missing key, or rejected request needs correction. Retrying the same invalid payload repeatedly increases load without improving the outcome.

For visual comparisons, persist the configuration with the baseline: width, full-page mode, delay, cookie handling, and hidden selectors. Without that context, a future run may compare two different capture specifications.

Performance and storage practices

Cache captures while they remain valid. If a page changes only after a content deployment, regenerate on that event instead of every page request. Use viewport mode for focused previews and full-page mode only when content below the fold matters.

Choose an output format for the next consumer. PNG preserves UI detail, WebP can suit web previews, and PDF belongs in document workflows. When the original is evidence, keep it and create derivative thumbnails instead of overwriting it.

Common PHP integration mistakes

  • Hardcoding the API key in PHP source or WordPress settings exposed to clients.
  • Running long batch captures inside a synchronous controller response.
  • Writing downloaded assets to unvalidated user-controlled paths.
  • Retrying permanent request errors indefinitely.
  • Capturing the same stable URL on every public request.
  • Comparing images created with different widths or timing options.
  • Treating generated AI output as verified fact without review.

Use the API documentation for endpoint fields and the package README for compatibility. Begin with one server-side screenshot call, then move stable work into the framework service or queue that owns it.

PHP screenshot API SDK FAQ

Which PHP version does the SDK require?

The current package requires PHP 8.1 or later together with the cURL and JSON extensions. Verify the package metadata before upgrading an existing application.

Can I use the SDK with Laravel?

Yes. Instantiate the client from server-side configuration and call it from controllers, services, console commands, or queued jobs according to the application's architecture.

Can I use it with Symfony or WordPress?

Yes. The client is a regular Composer package and does not require a specific framework. Keep the API key in server-side configuration rather than templates or public scripts.

Which SDK methods are available?

The verified PHP client provides screenshot, analyze, compare, and downloadTo methods for the main capture and asset workflows.

What can downloadTo save?

It accepts a direct asset URL or supported Snapshot Site responses. For a compare response, it prefers the diff image link when extracting the downloadable asset.

How should I store the API key in PHP?

Use an environment variable or the framework's secret-management system. Do not hardcode the key in a controller, repository, WordPress theme, or client-visible configuration.

Should screenshot requests run in a queue?

A queue is useful when capture is not required to complete the current web response, when jobs run in batches, or when retry and failure handling need to be isolated.

Can I call the REST API without the SDK?

Yes. The API accepts JSON over HTTPS. Use the SDK when its client methods and asset helper reduce maintenance in the PHP application.

Add one capture job to your PHP backend

Install the Composer package, load the key from server configuration, and test the request with a real page before moving it into a queue or application service.