PHP code example of spatie / laravel-screenshot
1. Go to this page and download the library: Download spatie/laravel-screenshot library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
spatie / laravel-screenshot example snippets
use Spatie\LaravelScreenshot\Facades\Screenshot;
Screenshot::url('https://example.com')->save('screenshot.png');
use Spatie\LaravelScreenshot\Facades\Screenshot;
Screenshot::url('https://example.com')
->width(1920)->height(1080)
->quality(80)
->save('screenshot.jpg');
use Spatie\LaravelScreenshot\Facades\Screenshot;
it('can take a screenshot', function () {
Screenshot::fake();
$this->get(route('screenshot'))->assertOk();
Screenshot::assertSaved(function ($screenshot) {
return $screenshot->url === 'https://example.com';
});
});