Configuration | laravel-screenshot | Spatie

 SPATIE

  Laravel Screenshot
=====================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-screenshot](https://spatie.be/docs/laravel-screenshot/v1)  Drivers  Configuration

 Version   v1

 Other versions for crawler [v1](https://spatie.be/docs/laravel-screenshot/v1)

- [ Introduction ](https://spatie.be/docs/laravel-screenshot/v1/introduction)
- [ Support us ](https://spatie.be/docs/laravel-screenshot/v1/support-us)
- [ Requirements ](https://spatie.be/docs/laravel-screenshot/v1/requirements)
- [ Installation &amp; setup ](https://spatie.be/docs/laravel-screenshot/v1/installation-setup)
- [ Questions and issues ](https://spatie.be/docs/laravel-screenshot/v1/questions-issues)
- [ Changelog ](https://spatie.be/docs/laravel-screenshot/v1/changelog)
- [ About us ](https://spatie.be/docs/laravel-screenshot/v1/about-us)

Basic usage
-----------

- [ Taking screenshots ](https://spatie.be/docs/laravel-screenshot/v1/basic-usage/taking-screenshots)
- [ Customizing screenshots ](https://spatie.be/docs/laravel-screenshot/v1/basic-usage/customizing-screenshots)
- [ Saving screenshots to disks ](https://spatie.be/docs/laravel-screenshot/v1/basic-usage/saving-screenshots-to-disks)
- [ Queued screenshot generation ](https://spatie.be/docs/laravel-screenshot/v1/basic-usage/queued-screenshot-generation)
- [ Testing screenshots ](https://spatie.be/docs/laravel-screenshot/v1/basic-usage/testing-screenshots)

Drivers
-------

- [ Configuration ](https://spatie.be/docs/laravel-screenshot/v1/drivers/configuration)
- [ Customizing Browsershot ](https://spatie.be/docs/laravel-screenshot/v1/drivers/customizing-browsershot)
- [ Using the Cloudflare driver ](https://spatie.be/docs/laravel-screenshot/v1/drivers/using-the-cloudflare-driver)
- [ Custom drivers ](https://spatie.be/docs/laravel-screenshot/v1/drivers/custom-drivers)

Advanced usage
--------------

- [ Extending with macros ](https://spatie.be/docs/laravel-screenshot/v1/advanced-usage/extending-with-macros)

 Configuration
=============

###  On this page

1. [ Switching drivers per screenshot ](#content-switching-drivers-per-screenshot)
2. [ Using a custom driver instance ](#content-using-a-custom-driver-instance)

This package supports multiple screenshot drivers. You can set the default driver via the `LARAVEL_SCREENSHOT_DRIVER` environment variable:

```
LARAVEL_SCREENSHOT_DRIVER=browsershot
```

Or in the config file:

```
// config/laravel-screenshot.php

return [
    'driver' => 'browsershot', // or 'cloudflare'
    // ...
];
```

Switching drivers per screenshot
--------------------------------------------------------------------------------------------------------------------------------------------------------

You can switch drivers for a specific screenshot using the `driver()` method:

```
use Spatie\LaravelScreenshot\Facades\Screenshot;

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

Using a custom driver instance
--------------------------------------------------------------------------------------------------------------------------------------------------

You can also pass a driver instance directly:

```
use Spatie\LaravelScreenshot\Drivers\BrowsershotDriver;
use Spatie\LaravelScreenshot\Facades\Screenshot;

$driver = new BrowsershotDriver([
    'chrome_path' => '/usr/bin/google-chrome',
]);

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