Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To capture a website from PHP, send its URL to a hosted screenshot API and save the returned image bytes—or use the returned image URL if that provider responds with JSON. This guide uses ScreenshotOne for the main PHP SDK example, then shows when a plain HTTP request or a different response format makes sense. The SDK commands and behavior below are provider-specific; check your chosen service’s current documentation for its PHP and extension requirements.

What a PHP screenshot API does

A hosted screenshot API accepts a capture request from your PHP application and performs the browser rendering on the provider’s infrastructure. Your application supplies the target URL and any capture settings, then handles the result. The result format matters: ScreenshotOne’s documented SDK example returns image bytes, while HTML to Image API’s HTML route returns JSON containing a CDN URL. You must use the storage code that matches the provider’s response; do not treat a URL response as image bytes or the reverse.

A PHP SDK can package authentication and request construction into familiar method calls. A raw HTTP request can reduce dependency on a vendor SDK, but you must follow the provider’s authentication and response format yourself. Neither approach runs a browser locally by default; the hosted service does the rendering.

Quick start with ScreenshotOne’s PHP SDK

1. Install the package

ScreenshotOne documents Composer installation with this command:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
composer require screenshotone/sdk:^1.0

The command adds the SDK to your Composer-managed project. Load Composer’s autoloader in the PHP script that makes the request.

2. Keep credentials out of source control

ScreenshotOne’s example uses access and secret key placeholders. The environment variable names below are an illustrative configuration convention, not names prescribed by ScreenshotOne. Set them in your deployment environment or local configuration, and do not commit actual keys to the repository.

export SCREENSHOTONE_ACCESS_KEY='your-access-key'
export SCREENSHOTONE_SECRET_KEY='your-secret-key'

Use the equivalent environment or secret-management mechanism for your hosting platform. The application needs to be able to read both values when it runs.

3. Capture a URL and save the returned bytes

This example follows ScreenshotOne’s documented SDK shape. It requests a full-page screenshot of https://example.com and writes the returned image bytes to a PNG file:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
<?php

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

use ScreenshotOneSdkClient;
use ScreenshotOneSdkTakeOptions;

$accessKey = getenv('SCREENSHOTONE_ACCESS_KEY');
$secretKey = getenv('SCREENSHOTONE_SECRET_KEY');

if (!$accessKey || !$secretKey) {
    throw new RuntimeException('Set SCREENSHOTONE_ACCESS_KEY and SCREENSHOTONE_SECRET_KEY.');
}

$client = new Client($accessKey, $secretKey);
$options = TakeOptions::url('https://example.com')
    ->fullPage(true);

$image = $client->take($options);

if ($image === false || $image === '') {
    throw new RuntimeException('The screenshot response was empty.');
}

$path = __DIR__ . '/screenshot.png';
if (file_put_contents($path, $image) === false) {
    throw new RuntimeException('Could not write the screenshot file.');
}

echo "Saved screenshot to {$path}" . PHP_EOL;

ScreenshotOne documents take() as returning the image bytes, so the example writes those bytes directly. It does not assume that every API returns a binary image. For the options supported by ScreenshotOne, see its official documentation.

4. Make options match the capture you need

The example enables full-page capture. ScreenshotOne’s documentation also demonstrates a delay and latitude, longitude, and accuracy options. These are optional controls, not requirements for every capture. Add a delay when a page needs time to render content; use location settings only when the page’s behavior genuinely depends on geography. A full-page capture is useful for a long page, but creates a taller image than a viewport-only capture.

When a PHP SDK is not the right fit

Provider SDKs are not interchangeable. Before installing one, confirm its package name, PHP support, authentication, and result format. For example, HTML to Image API documents the Composer package html2img/html2img-php, requires PHP 8.3 or newer and cURL, and uses an Html2imgClient. Its HTML route returns a JSON response containing a CDN URL; its website screenshot route accepts a URL and capture options. Store or consume that URL according to your application’s needs rather than writing the JSON response to a file with a .png extension. See the provider’s PHP documentation.

ScreenshotAPI’s Packagist package page documents composer require screenshotapi/sdk, PHP 8.1 or newer, an API key in the x-api-key header, and an example that saves the result to a file. Its page identifies v1.0.1 as published on June 29, 2026, and last updated on July 29, 2026; those are package-page metadata, not confirmation that v1.0.1 is still the newest release. Check the package page for current details before pinning a version: ScreenshotAPI on Packagist.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

These requirements apply to the named packages only. Do not infer a universal PHP version or extension requirement for screenshot APIs from one vendor’s documentation.

Use a raw HTTP request when you want to avoid an SDK

A raw request is an option when the provider documents an HTTP endpoint and you prefer to make the request with PHP’s HTTP client or cURL. Authentication headers, parameters, timeouts, and response parsing are provider-specific. For example, the cited providers use different authentication conventions: ScreenshotAPI documents an x-api-key header, while the HTML to Image API says to keep its key in the environment and send it using an X-API-Key header. Do not copy a header or endpoint from one provider into a request to another.

Before writing the request code, establish whether the endpoint returns raw image bytes, a URL, or JSON. For raw bytes, validate the HTTP status and content type before saving. For a JSON response, decode it and handle the returned URL as documented. Set a finite timeout, and surface an informative error when the provider returns an unsuccessful status rather than saving an error body as an image.

Or skip the browser setup

ScreenshotNeo is a hosted screenshot API and MCP server for developers. It accepts one GET request with a URL and returns a screenshot as PNG, JPEG, or WebP, or a PDF. Its API base is ScreenshotNeo. The following cURL request saves a WebP capture of Stripe’s homepage; replace the URL with the site you want to capture:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

For the available parameters and response behavior, use the ScreenshotNeo API documentation. In PHP, the same endpoint can be called with an HTTP client such as Guzzle; this example uses the common requests syntax only as an illustration of the API’s GET parameters:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

For PHP, use the same GET endpoint and parameters through your preferred HTTP client, then save the response body as bytes. ScreenshotNeo’s parameter names also work with the names other screenshot APIs use, which can ease migration. Its clean-shot workflow accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month without a card.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common problems and fixes

  • Composer cannot find the package: Check that you used the exact package name for your selected provider and that Composer is running in the project directory containing composer.json. Package names differ between vendors.
  • Missing class or autoloader: Confirm the Composer install completed, that your script requires vendor/autoload.php, and that the use statements match the SDK’s documented namespace.
  • Authentication fails: Check that the key values are present in the runtime environment, belong to the provider you are calling, and are sent in the provider’s documented form. A key in an x-api-key header is not interchangeable with a query parameter or a different credential type.
  • The saved file is not an image: Inspect the HTTP status, response headers, and body. The server may have returned a JSON error or a URL response rather than image bytes. Use the provider’s documented response handling before writing a file.
  • PHP reports an unsupported version or missing cURL: Verify the selected package’s requirements against the PHP runtime and extensions enabled in the environment that executes the script. The HTML to Image API package, for example, documents PHP 8.3+ and cURL; that requirement does not apply universally.
  • The screenshot is incomplete: The page may render content after initial load. Consider a supported delay or other documented wait option, and check whether full-page capture is enabled if content below the viewport is missing.
  • The file cannot be written: Check the destination path and the PHP process’s write permissions. Save to a directory intended for generated files rather than assuming the script directory is writable.

Reliability, performance, and cost decisions

A hosted API avoids operating browser-rendering infrastructure in your PHP application, but the capture still depends on both the target site and the provider completing the request. Use finite timeouts in application code, handle unsuccessful responses, and avoid treating a failed capture as a valid image. If your application needs to serve a screenshot repeatedly, consider whether to store the generated file or use a provider-returned URL, depending on the response and retention behavior documented by that provider.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Full-page captures and delayed rendering can require more work than a basic viewport capture. Enable only the options the page needs, and test the output against pages with the content and layout your application actually handles. The documentation cited here does not establish comparable prices, quotas, or latency across ScreenshotOne, HTML to Image API, and ScreenshotAPI, so choose a provider based on verified current terms rather than assuming those values.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

FAQ

Can PHP take a website screenshot without a screenshot API?

Yes, but this quick start focuses on hosted APIs. A local browser-based implementation would require a separate browser-rendering setup and operational decisions that the SDK examples here avoid.

Can I use an API to render HTML instead of a live website?

Some providers expose HTML-to-image routes. HTML to Image API documents such a route and returns a CDN URL in its JSON response; its format and integration differ from a binary screenshot response.

Should I request a full-page image every time?

No. Use full-page capture when the screenshot must include content beyond the initial viewport; otherwise, a viewport capture may better match the intended output.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.