Is there any way of taking a screenshot of a website in PHP, then saving it to a file?
Well, PhantomJS is a browser that can be easily put on a server and integrate it to php. You can find the code in WDudes. They have included lot more features like specifying the image size, cache, download as a file or display in img src etc.
URL Parameters
Width and Height: screenshot.php?url=google.com&w=1000&h=800
With cropping: screenshot.php?url=google.com&w=1000&h=800&clipw=800&cliph=600
Disable cache and load fresh screesnhot:
screenshot.php?url=google.com&cache=0
To download the image: screenshot.php?url=google.com&download=true
You can see the tutorial here: Capture Screenshot of a Website using PHP without API