Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk6 min

How to Use a Screenshot API in a Laravel App in India

A practical Laravel guide to webpage screenshots with Browsershot or Cloudflare Browser Rendering, including current Spatie requirements and a hosted API alternative.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a Laravel app, the practical choices are Spatie’s laravel-screenshot package using its default local Browsershot driver, the same package using its Cloudflare driver, or a direct call to Cloudflare Browser Rendering. The current Spatie requirements specify PHP 8.4+ and Laravel 12+, so check your app’s versions first. The integration steps below are generic; the cited documentation does not establish India-specific pricing, taxes, service eligibility, data residency, capture location, or latency.

Choose the capture route that fits your app

Route What runs the browser What you need Best fit
Spatie package with Browsershot Chromium on your Laravel server Compatible PHP and Laravel, plus Node.js and Chrome/Chromium You want a Laravel facade and control of the capture runtime.
Spatie package with Cloudflare Cloudflare Browser Rendering Compatible PHP and Laravel, Cloudflare account, Browser Rendering enabled, account ID and API token You want Spatie’s Laravel interface without installing a browser runtime on the app server.
Direct Cloudflare API Cloudflare Browser Rendering Cloudflare account, Browser Rendering Write permission, account ID and API token You want to manage Cloudflare request options and response handling directly.

Spatie describes its package as a way to take screenshots of web pages in Laravel apps. Its documentation presents Browsershot as the default driver and Cloudflare as an alternative. Spatie Laravel Screenshot introduction · Requirements

As an Amazon Associate I earn from qualifying purchases.

Check Laravel and PHP compatibility first

The current Spatie Laravel Screenshot requirements page lists PHP 8.4 or newer and Laravel 12 or newer. Confirm your app meets both requirements before using the package route; if it does not, check the package’s current requirements and compatible release before proceeding. Spatie requirements

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

Route 1: Take a screenshot with Spatie and Browsershot

Install the package and browser dependencies

  1. Install the package with Composer: composer require spatie/laravel-screenshot.
  2. Install Node.js and a Chrome or Chromium binary in the environment where screenshots will run. Composer installs the Laravel package, not those browser-runtime dependencies.
  3. If the binaries are not found automatically, configure the paths using the package’s supported environment settings, such as LARAVEL_SCREENSHOT_CHROME_PATH, LARAVEL_SCREENSHOT_NODE_BINARY and LARAVEL_SCREENSHOT_NPM_BINARY.

See Spatie installation and setup and its requirements for the package’s setup details.

Capture and save a page

The basic facade call saves a screenshot to a path writable by the Laravel process:

<?php

use SpatieLaravelScreenshotFacadesScreenshot;

Screenshot::url('https://example.com')->save('screenshot.png');

The documented defaults are a 1280 × 800 viewport, device scale factor 2, PNG output, and a networkidle2 wait. Set dimensions and quality when you need a different output:

Screenshot::url('https://example.com')
    ->width(1920)
    ->height(1080)
    ->quality(80)
    ->save('screenshot.jpg');

For full-page capture, clipping, output formats and device-scale controls with Browsershot, consult Browsershot image generation. These documented defaults and controls are configuration details, not performance guarantees.

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

Route 2: Use Spatie’s Cloudflare driver

This route keeps the Laravel facade but sends the capture to Cloudflare Browser Rendering, so the Laravel server does not need Node.js or a Chrome binary. It does require a Cloudflare account with Browser Rendering enabled, an account ID, and an API token with the required Browser Rendering permission.

Configure credentials on the server

Set the driver and credentials in the server-side environment:

LARAVEL_SCREENSHOT_DRIVER=cloudflare
CLOUDFLARE_API_TOKEN=your-api-token
CLOUDFLARE_ACCOUNT_ID=your-account-id

Keep the token in server-side configuration; do not send it to browser clients. Follow Spatie’s installation and setup instructions for configuring the driver.

Select Cloudflare for a capture

You can set Cloudflare as the default driver with the environment setting above, or select it for an individual capture through the package configuration’s driver('cloudflare') call. The configuration documentation describes the driver selection options: Spatie driver configuration.

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

Route 3: Call Cloudflare Browser Rendering directly

Cloudflare’s screenshot endpoint is POST https://api.cloudflare.com/client/v4/accounts/{account_id}/browser-rendering/screenshot. It accepts URL or HTML input and options including viewport, full-page capture, output type and quality, selectors, clipping, and page-wait settings. Authenticate with a Bearer API token that has Browser Rendering Write permission. Cloudflare screenshot endpoint

Laravel HTTP-client example

Store the account ID and token in server-side configuration, then send the request as JSON. This example shows the documented request shape; adapt configuration names and response handling to your app:

<?php

use IlluminateSupportFacadesHttp;

$accountId = config('services.cloudflare.account_id');
$url = 'https://example.com';

$response = Http::withToken(config('services.cloudflare.browser_rendering_token'))
    ->acceptJson()
    ->post("https://api.cloudflare.com/client/v4/accounts/{$accountId}/browser-rendering/screenshot", [
        'url' => $url,
        'screenshotOptions' => [
            'type' => 'png',
            'fullPage' => true,
            'viewport' => ['width' => 1280, 'height' => 800],
        ],
    ]);

$data = $response->json();

if (! $response->successful() || ! ($data['success'] ?? false)) {
    throw new RuntimeException('Cloudflare screenshot request failed: '.json_encode($data['errors'] ?? []));
}

// Handle the successful response according to the requested output encoding.

Check both the HTTP status and Cloudflare’s success and errors fields before treating the capture as successful. The endpoint documentation includes a rate-limit error example, so handle failures rather than assuming every request returns an image. The exact response processing depends on the selected output encoding and documented response format. If you need page HTML and a screenshot together, Cloudflare has a separate snapshot endpoint: Cloudflare snapshot endpoint.

Run captures reliably in a Laravel application

Choose synchronous or queued work

A capture can take long enough that an HTTP request should not wait for it. Spatie supports saveQueued() and queue, connection, delay, and custom-job settings. Its queued-generation documentation says saveQueued() cannot be combined with withBrowsershot(); check that constraint when configuring queued captures. Spatie queued screenshot generation

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

Plan for runtime and API failures

  • For Browsershot, verify Node.js and Chrome/Chromium are installed in the actual worker or server environment, and that configured binary paths are valid.
  • For Cloudflare, verify the account ID, token, permission and Browser Rendering enablement. Keep credentials out of client-side code and logs.
  • For direct API calls, inspect both transport-level status and Cloudflare’s JSON success/error fields. Handle rate-limit responses and other failures in the application.
  • Write output only to a path the Laravel process can access, and make the application’s response or job status distinguish a failed capture from a completed one.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

India-specific considerations

The integration instructions above are not specific to India. The cited documentation does not establish whether a particular Cloudflare account or feature is available to every Indian user, what local taxes or prices apply, where a capture is processed, or what latency an app in India will experience. Confirm current account eligibility and commercial terms with the relevant provider, and measure latency from your own deployment region before making a regional design decision.

Or skip the browser setup

ScreenshotNeo is a screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP or PDF, without installing Node.js or Chromium in your Laravel environment. Cookie banners are accepted and removed before capture, along with known consent platforms, newsletter popups and chat widgets; these cleanup steps can be turned off. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status. AI agents can use its MCP server tools, including take_screenshot, get_page_info and capture_pdf.

For example, use Laravel’s HTTP client to make the API GET request and save its response:

<?php

use IlluminateSupportFacadesHttp;

$response = Http::get('https://api.screenshotneo.com/v1/shot', [
    'access_key' => config('services.screenshotneo.access_key'),
    'url' => 'https://example.com',
]);

$response->throw();
file_put_contents(storage_path('app/screenshot.webp'), $response->body());

See the ScreenshotNeo documentation for the API options and response details. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Sign up free for 1,000 screenshots a month, with no card required.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Frequently Asked Questions

Can I use the Cloudflare route without installing Node.js on my Laravel server?

Yes. Spatie’s Cloudflare driver and the direct Cloudflare API route use Cloudflare Browser Rendering rather than a local Node.js and Chrome/Chromium runtime.

Can the direct Cloudflare endpoint capture HTML instead of a URL?

The screenshot endpoint documentation lists URL or HTML input. Use its documented request fields for the input type and options you need.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.