PHP website screenshots

PHP website screenshots

Generate website screenshots with PHP and Laravel

Sample code to quickly generate a render link using the urlbox-php composer package.

Check out our Composer package, and Github repo

use Urlbox\Screenshots\Urlbox;
$urlbox = Urlbox::fromCredentials( 'API_KEY', 'API_SECRET' );
 
$options = [
    // only required option is a url:
    'url' => 'example.com',
 
    // specify any other options to augment the screenshot...
    'width' => 1280,
    'height' => 1024,
];
 
// Create the Urlbox URL
$urlboxUrl = $urlbox->generateSignedUrl( $options );
// $urlboxUrl is now 'https://api.urlbox.io/v1/API_KEY/TOKEN/png?url=example.com'
 
// Generate a screenshot by loading the Urlbox URL in an img tag:
echo '<img src="' . $urlboxUrl . '" alt="Test screenshot generated by Urlbox">'