PHP code example of assisted-mindfulness / browsershot

1. Go to this page and download the library: Download assisted-mindfulness/browsershot 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/ */

    

assisted-mindfulness / browsershot example snippets


use AssistedMindfulness\Browsershot\Browsershot;

Browsershot::url('https://example.com')->save($pathToImage);

Browsershot::url('https://example.com')
   ->setChromePath($pathToChrome)
   ->save($pathToImage);

Browsershot::url('https://example.com')
    ->windowSize(640, 480)
    ->save($pathToImage);

Browsershot::url('https://example.com')
    ->windowSize(1920, 1080)
    ->fit(Manipulations::FIT_CONTAIN, 200, 200)
    ->save($pathToImage);

Browsershot::url('https://example.com')
    ->deviceScaleFactor(2)
    ->save($pathToImage);

Browsershot::url('https://example.com')
    ->windowSize(640, 480)
    ->greyscale()
    ->save($pathToImage);

Browsershot::url('https://example.com')
    ->userAgent('My Special Snowflake Browser 1.0')
    ->save($pathToImage);

Browsershot::url('https://example.com')
    ->timeout(120)
    ->save($pathToImage);

// a pdf will be saved
Browsershot::url('https://example.com')->save('example.pdf');

Browsershot::url('https://example.com')->savePdf('example.pdf');

Browsershot::url('https://example.com')->bodyHtml(); // returns the html of the body

Browsershot::html('<h1>Hello world!!</h1>')->save('example.pdf');