PHP makes it easy to do different jobs by using simple commands. If you are a PHP developer you will know that PHP does not require too much coding to do different things and it is not too much lengthy code to take website screenshot using PHP you can see the code below copy it and run it in your localhost server to get screenshot of any website.
simply create a new index.php file in paste the following code in it.
<?php //website url $siteURL = "http://www.softwebtuts.com"; //call Google PageSpeed Insights API $googlePagespeedData = file_get_contents("https://www.googleapis.com/pagespeedonline/v2/runPagespeed?url=$siteURL&screenshot=true"); //decode json data $googlePagespeedData = json_decode($googlePagespeedData, true); //screenshot data $screenshot = $googlePagespeedData['screenshot']['data']; $screenshot = str_replace(array('_','-'),array('/','+'),$screenshot); //display screenshot image echo "<img src=\"data:image/jpeg;base64,".$screenshot."\" />"; ?>
Replacements:You simply have to replace the URL of website of which you want to take screenshot like in the above code you have to replace http://www.softwebtuts.com the URL of website of which you want to take screenshot.
In the code provided above we have to use Google pagespeed insights API to capture screenshot of a website.