tuhin18003/puppteer-php-bridge

A PHP Class to interact with Puppeteer and capture screenshot of a webpage

dev-master 2019-03-14 03:11 UTC

This package is auto-updated.

Last update: 2024-05-14 19:45:40 UTC


README

Web site screenshot tool based on PHP and puppeteer You can use it to take screenshots for testing or monitoring service

Install

Via Composer

$ composer require tuhin18003/puppteer-php-bridge

After install the composer package go inside the jobs folder, then install the npm package

$ npm install

Usage

With this library you can make use of PhantomJs to screenshot a website.

Check our demo or read the following instructions.

Creating the object, you can either pass the url on the constructer or set it later on

use PuppetBridge\Capture;

try{
    $screenCapture = new Capture();
    $screenCapture->setImageType( 'png' );
    $screenCapture->setUrl( 'https://google.com' );
    $screenCapture->setTop(0);
    $screenCapture->setLeft(0);
    $screenCapture->setWidth( '600' );
    $screenCapture->setHeight( '600' );
    $screenCapture->save( 'images/testimg.png' ); // make sure images folder is writable

} catch (Exception $ex) {
    echo $ex->getMessage();
}

License

The MIT License (MIT). Please see License File for more information.

Credits

Thanks to the puppeteer (LICENSE) guys for creating their awesome WebKit scripting interface.

Special Thanks