PHP Integration
Screenshot API for PHP & Laravel
Capture pixel-perfect website screenshots with the official nodium/screenshot-sdk package. Native Laravel integration, fluent builder API, and Guzzle-powered HTTP client with automatic retries.
Install via Composer
Requires PHP 8.1+ and Guzzle 7.0+ (installed automatically).
composer require nodium/screenshot-sdkQuick Start & Laravel Integration
From a quick script to a full Laravel controller in minutes.
screenshot.php
<?php
require_once 'vendor/autoload.php';
use Nodium\Screenshot\Client;
$client = new Client('YOUR_API_KEY');
$result = $client->take()
->url('https://example.com')
->format('png')
->viewport(1440, 900)
->fullPage(true)
->blockAds(true)
->imageQuality(95)
->execute();
file_put_contents('screenshot.png', $result->data);
echo "Rendering time: {$result->headers['rendering_seconds']}s\n";
echo "File size: " . round($result->headers['size_bytes'] / 1024, 1) . " KB\n";ScreenshotController.php -- Laravel
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Nodium\Screenshot\Client;
use Nodium\Screenshot\Exceptions\NodiumAPIException;
class ScreenshotController extends Controller
{
public function __construct(
private readonly Client $screenshot,
) {}
public function capture(Request $request)
{
$request->validate(['url' => 'required|url']);
try {
$result = $this->screenshot->take()
->url($request->input('url'))
->format('png')
->viewport(1280, 1024)
->execute();
return response($result->data, 200, [
'Content-Type' => 'image/png',
'Content-Disposition' => 'inline; filename="screenshot.png"',
]);
} catch (NodiumAPIException $e) {
return response()->json([
'error' => $e->getErrorCode(),
'message' => $e->getMessage(),
], $e->getHttpStatus());
}
}
}AppServiceProvider.php -- Register the client
// app/Providers/AppServiceProvider.php
use Nodium\Screenshot\Client;
public function register(): void
{
$this->app->singleton(Client::class, function ($app) {
return new Client(config('services.nodium.api_key'), [
'timeout' => 60,
'retries' => 3,
]);
});
}Built for PHP Developers
A modern PHP SDK designed for Laravel, Symfony, and vanilla PHP projects.
Laravel Native
Register as a singleton via service providers. Inject into controllers with constructor injection. Works with Laravel 10+.
Fluent Builder
Chain methods like
->url()->format()->viewport() for readable, expressive screenshot configuration.Automatic Retries
Built-in exponential backoff retries on 5xx errors with Guzzle. Configurable retry count for production reliability.
Typed Exceptions
Catch
NodiumAPIException with error codes, HTTP status, and retryability checks for precise error handling.Blade Integration
Generate signed URLs and embed them directly in Blade templates. Display live website previews without server-side processing.
PHP 8.1+ Modern
Built with readonly properties, enums, named arguments, and constructor promotion. Clean, modern PHP architecture.
Why Nodium for PHP?
Skip the complexity of managing headless browsers in your PHP environment.
Without Nodium
- ✗Install Chrome/Chromium on your PHP server
- ✗Manage chrome-php or browsershot with process control
- ✗Configure shared hosting to run headless browsers
- ✗Handle Node.js dependency in a PHP stack
- ✗Debug rendering differences across environments
With Nodium
- One Composer install, zero system dependencies
- Pure PHP SDK -- no Node.js or browser required
- Works on shared hosting, VPS, and cloud platforms
- Consistent rendering across all environments
- 145+ parameters including ads, dark mode, devices
Supported Output Formats
Capture websites in any format your PHP application needs.
PNGJPEGWebPAVIFHEIFTIFFGIFPDFMP4WebM
Start Capturing Screenshots with PHP
Free tier included. No credit card required. Get your API key and integrate with Laravel in minutes.