Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
The dependable way to capture a website screenshot in PHP is to automate a real browser. Install a PHP browser library, open the URL, wait for navigation and page-specific content, then save the viewport, an element, or the full page to a writable image path. Playwright for PHP, chrome-php/chrome, and Spatie Browsershot are the practical choices documented for this workflow.
Choose the PHP approach that matches your runtime
| Library | Browser/runtime | Best fit | Documented capture scope |
|---|---|---|---|
| Playwright for PHP | PHP 8.2+, Node.js 20+, Playwright-managed browsers | Projects wanting a modern browser-automation API and Chromium, Firefox, or WebKit | Screenshot saving through the Playwright API; browser launch or connection to an existing browser |
| chrome-php/chrome | PHP 7.4–8.5 and Chrome/Chromium 65 or later | Applications that already manage a Chrome executable | PNG, JPEG, WebP, clipped regions, and documented full-page capture |
| Spatie Browsershot | Puppeteer with headless Chrome | Rendering URLs, supplied HTML, or HTML files into images or PDFs | Image/PDF rendering and HTML returned after JavaScript execution |
The versions in this table are the requirements stated by the projects’ documentation and checked on September 29, 2026. Package requirements and APIs change, so verify the selected project’s current installation page before deployment. There is no reliable universal claim that one option is fastest: rendering time depends on the target site, browser startup, network, JavaScript, and your server.
Option 1: Playwright for PHP
Playwright is the strongest choice when you need a browser-automation API and may test more than Chromium. Its PHP documentation exposes Chromium, Firefox, and WebKit entry points. It also supports launching a browser from PHP or connecting to a separately managed browser; the documented Playwright protocol is the recommended and more complete connection mode.
Recommended Free Tools
Install PHP, Node.js, and browsers
- Use PHP 8.2 or newer and Node.js 20 or newer.
- From your project directory, install the package:
composer require --dev playwright-php/playwright - Install the browser binaries:
vendor/bin/playwright-install --browsers - Ensure the account running PHP can write to the destination directory.
Capture a rendered page
<?php
require __DIR__ . '/vendor/autoload.php';
use PlaywrightPlaywright;
$playwright = Playwright::create();
$browser = $playwright->chromium()->launch(['headless' => true]);
$page = $browser->newPage();
try {
$page->goto('https://example.com');
$page->screenshot(['path' => __DIR__ . '/screenshot.png', 'fullPage' => true]);
} finally {
$browser->close();
$playwright->stop();
}
The documented basic example navigates to https://example.com and saves a PNG. Replace the URL and output path for your application. A viewport screenshot captures only what is visible; fullPage asks the browser to extend the capture to the page’s full scrollable height where supported by the installed API version.
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
Wait for application content, not an arbitrary sleep
Navigation completion does not prove that a single-page application has finished rendering. Wait for a selector that represents the content you need, or use the readiness mechanism provided by your installed Playwright version. A fixed delay can be useful for a known animation, but it is slower and less reliable than waiting for a meaningful element. There is no one wait value that guarantees every website is visually settled.
<?php
// After creating $page and before taking the screenshot:
$page->goto('https://example.com/dashboard');
$page->locator('[data-report-ready="true"]')->waitFor();
$page->screenshot([
'path' => __DIR__ . '/dashboard.png',
'fullPage' => true,
]);
Capture a region or element
When the requirement is a chart, card, or other component rather than the entire document, target that element with the screenshot API exposed by your installed Playwright release. Element screenshots avoid oversized files and make layout tests easier to compare. Confirm the exact method names in the API reference for the package version you install.
Option 2: chrome-php/chrome
chrome-php/chrome is a PHP wrapper around a Chrome DevTools connection. Its documentation lists PHP 7.4 through 8.5 and a Chrome/Chromium executable version 65 or later. It is a practical fit when your deployment image already includes Chrome and you want explicit control over that executable.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchInstall and capture a PNG
composer require chrome-php/chrome
<?php
require __DIR__ . '/vendor/autoload.php';
use HeadlessChromiumBrowserFactory;
$factory = new BrowserFactory();
$browser = $factory->createBrowser([
'headless' => true,
]);
try {
$page = $browser->createPage();
$page->navigate('https://example.com')->waitForNavigation();
$page->screenshot()->saveToFile(__DIR__ . '/screenshot.png');
} finally {
$browser->close();
}
The README documents PNG, JPEG, and WebP output. Set the format and quality through the screenshot options supported by your installed release. The same documentation describes clipped-region screenshots and full-page capture by supplying a clip that covers the document and enabling capture beyond the viewport.
Full-page and clipped capture
<?php
$evaluation = $page->evaluate('({
width: document.documentElement.scrollWidth,
height: document.documentElement.scrollHeight
})')->getReturnValue();
$page->screenshot([
'format' => 'webp',
'clip' => [
'x' => 0,
'y' => 0,
'width' => $evaluation['width'],
'height' => $evaluation['height'],
'scale' => 1,
],
'captureBeyondViewport' => true,
])->saveToFile(__DIR__ . '/full-page.webp');
For a component, replace the clip coordinates with the element’s bounding rectangle. Measure after the content has rendered; otherwise a late-loading chart can be cut off.
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
Option 3: Spatie Browsershot
Browsershot renders a URL through Puppeteer and headless Chrome. It also accepts supplied HTML and HTML files, and can return the document body after JavaScript has run. Current Browsershot uses Puppeteer; its older v2 Chrome CLI route is no longer maintained and should not be the default for a new project.
Render a URL to an image
composer require spatie/browsershot
<?php
require __DIR__ . '/vendor/autoload.php';
use SpatieBrowsershotBrowsershot;
Browsershot::url('https://example.com')
->windowSize(1440, 900)
->fullPage()
->waitUntilNetworkIdle()
->save(__DIR__ . '/screenshot.png');
Use a selector-based wait when your page has a definitive ready element, if supported by your installed Browsershot version. Network-idle waiting is useful for pages that finish their requests, but analytics, ads, or live feeds can keep a connection open indefinitely. Set a bounded timeout in production.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Render supplied HTML
<?php
$html = '<!doctype html><html><body><h1>Invoice</h1></body></html>';
Browsershot::html($html)
->windowSize(1200, 800)
->save(__DIR__ . '/invoice.png');
Viewport, element, or full page?
- Viewport: Use it for a realistic above-the-fold preview, social card, or responsive breakpoint check. Set the width and height explicitly so runs are reproducible.
- Element or clip: Use it for a product card, chart, invoice, or test fixture. Wait until the element exists and measure its final bounds.
- Full page: Use it for documentation, audits, and archival captures. Very long pages can create large images and may contain lazy-loaded sections that are not present until scrolled.
Full-page behavior differs by library and browser version. If lazy images matter, scroll or otherwise trigger loading before capture, then verify the resulting dimensions and file contents.
File paths, permissions, and application safety
Use an absolute path based on __DIR__ or a configured storage directory. The PHP-FPM, queue, or container user—not your shell account—must have write permission. After saving, check that the file exists and has a non-zero size before returning success.
$output = __DIR__ . '/storage/screenshots/page.png';
if (!is_dir(dirname($output))) {
mkdir(dirname($output), 0775, true);
}
// Run the browser capture here.
if (!is_file($output) || filesize($output) === 0) {
throw new RuntimeException('Screenshot was not written.');
}
Do not pass untrusted user input directly into shell commands or browser flags. Validate allowed URL schemes, apply network egress rules, and consider SSRF protections when users can choose the target URL. Keep browser processes isolated and close them in a finally block.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Reliability and performance practices
- Reuse a managed browser for batches when the library supports it; launching a new browser for every image adds startup cost.
- Use a fixed viewport, device scale, locale, timezone, and user agent when visual output must be comparable.
- Wait for the specific content required, then impose a timeout so a broken third-party request cannot hold a worker forever.
- Capture after fonts and images are available. For lazy loading, scroll through the page before a full-page shot.
- Store images outside the public web root unless they are intentionally public, and generate collision-resistant filenames.
- Log the URL, wait condition, browser version, elapsed time, output path, and exception message. Never log credentials or cookies.
- Limit concurrent browser pages according to available CPU and memory; browser rendering is substantially heavier than an HTTP request.
Troubleshooting common failures
“Browser executable not found”
Playwright needs its documented browser-install command; chrome-php/chrome needs a compatible Chrome/Chromium executable; Browsershot needs its Puppeteer/Chrome runtime. Install the dependency in the same image or host that runs PHP, and configure the executable path when your package version supports it.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
The file is blank or only partly rendered
Navigation may have completed before client-side rendering. Wait for a content selector, trigger lazy loading, and ensure the page is not showing a cookie wall or bot challenge. Capture a diagnostic screenshot and inspect console or navigation errors.
Timeouts on pages that work in a normal browser
Headless execution can encounter authentication, geolocation, robots controls, slow third-party resources, or an infinite request. Increase the timeout only within a limit, block nonessential resources where supported, and provide required headers or cookies through the library’s documented options.
Permission denied or missing output
Check the directory owner and mode for the PHP worker user, use an absolute path, create the directory before capture, and verify available disk space. A successful browser call does not guarantee that PHP can write the destination.
Full-page output is cropped
Confirm that the page’s final height was measured after rendering and use the library’s documented full-page or capture-beyond-viewport option. For very long documents, split captures or use PDF output when a single enormous bitmap is impractical.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
Fonts, images, or colors differ from local development
The server may lack fonts, use a different device scale, or load a different responsive layout. Install the required fonts, set the viewport explicitly, wait for font and image readiness, and record the browser and OS used for repeatability.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
ScreenshotNeo provides a website screenshot API: one GET request returns PNG, JPEG, WebP, or a PDF. Before capture it accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; 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 whether the request was billed. It also offers an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
Request options cover full-page shots with lazy images loaded, CSS-selector elements, dark mode, 12 device presets or custom viewports, retina scale, PDF paper and page ranges, custom CSS and JavaScript, clicks, selector or network-idle waits, ad/tracker/request blocking, headers, cookies, user agents, Authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed public-image links, asynchronous jobs with signed webhooks, bulk capture of 100 URLs per call, a usage API, and an OpenAPI specification. Common parameter names used by other screenshot APIs also work.
See the ScreenshotNeo documentation for the current parameter list. The following PHP-compatible HTTP call saves the response directly:
<?php
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)
The line above is the documented Python example, included for reference. In PHP, use cURL or your HTTP client to make the same GET request:
<?php
$url = 'https://api.screenshotneo.com/v1/shot?' . http_build_query([
'access_key' => 'YOUR_API_KEY',
'url' => 'https://stripe.com',
]);
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 90,
]);
$bytes = curl_exec($ch);
if ($bytes === false) {
throw new RuntimeException(curl_error($ch));
}
curl_close($ch);
file_put_contents(__DIR__ . '/shot.webp', $bytes);
The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing gives two months free, and every feature is on every plan. Sign up for the free ScreenshotNeo plan.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
FAQ
Can PHP take a screenshot without a browser?
Not of a modern, JavaScript-rendered website reliably. An HTTP client downloads source; a browser is needed to execute scripts, lay out CSS, load fonts, and paint the page.
Which format should I store?
PNG preserves crisp text and transparency, JPEG is smaller for photographic pages, and WebP often provides a useful size-quality compromise. Choose based on downstream consumers and the formats your selected library supports.
Can I run these libraries in a queue worker?
Yes, provided the worker image includes the PHP package, browser runtime, writable storage, sufficient memory, and bounded timeouts. Always close browser resources even when a job fails.
Frequently Asked Questions
Can I capture an authenticated page?
Yes. Supply the session cookies or authorization headers through the browser library’s documented context or request options, and protect those credentials in logs and storage.
Why does a screenshot differ between servers?
Viewport, device scale, fonts, browser version, timezone, locale, and available network resources can all change rendering. Pin the variables that matter and record them with each capture.
Is a full-page screenshot always one continuous image?
Usually the library stitches or requests a capture beyond the viewport, but extremely long pages and lazy content can exceed practical image dimensions. Verify the output and consider multiple captures or PDF for large documents.
Quick Recap
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.

