This module ZF2 will help you to generate screenshots of your website based on the API webthumbnail.org
-
Add to your
composer.json
:"require": { "cwplus/web-thumbnail": "dev-master" }
-
Now tell composer to download MvlabsSnappy by running the command:
$ php composer.phar update
# Install ZF2 Module
git clone https://github.com/cwplus/web-thumbnail.git vendor/cwplus/web-thumbnail
-
Enabling it in your
application.config.php
file.<?php return array( 'modules' => array( // ... 'Webthumbnail', ), // ... );
After installing Webthumbnail, copy
./vendor/cwplus/Webthumbnail/config/webthumbnail.local.php.dist
to
./config/autoload/webthumbnail.local.php
and change the binaries path and add path to saved web thumbs image.
# /config/autoload/webthumbnail.local.php
<?php
return array(
'webthumbnail'=>array(
'path'=> './public/files/site/',
)
);
The module registers one service : WebthumbnailService
$WebthumbnailService = $this->serviceLocator->get('WebthumbnailService')->setUrl('http://www.creationwebplus.be');
$WebthumbnailService = WebthumbnailService->setPath('./public/files/site/');
If you want to declare the width or height of the image created : ( 100 < width < 500; 100 < height < 500 )
$WebthumbnailService = WebthumbnailService->setWidth(250);
$WebthumbnailService = WebthumbnailService->setHeight(250);
$WebthumbnailService = WebthumbnailService->setFormat('png');
$WebthumbnailService = WebthumbnailService->setFormat('png');
$WebthumbnailService = WebthumbnailService->setScreen(1024);
$WebthumbnailService->captureToFile('screenshot.png');
$WebthumbnailService->captureToOutput();
Webthumbnail module is based on the API of webthumbnail.org