This can absolutely be done, it just takes a little more than PHP to make it happen. I have an application written in PHP that takes snapshots of websites at certain intervals. It's a bit tricky to get going but here's the steps I took on a Linux machine:
- Install Xvfb (or vnc-server) to emulate an X Windows session in memory. Start Xvfb on display :1
- Install Firefox
- Install imagemagick
- Create a bash script to run Firefox on the desired URL. Mine looked like this:
.
#!/bin/bash
DISPLAY=:1 firefox &
sleep 2s
DISPLAY=:1 firefox -kill-all &
sleep 1s
DISPLAY=:1 firefox -url $1 &
sleep 5s
DISPLAY=:1 import -window root /var/www/images/screenshots/$2.png
- Execute the script from PHP:
.
exec ('sh ../scripts/screencap.sh ' . $url . ' ' . $file_name);
The trickiest part for me was to get the browser to be full screen when the screenshot occurred. Because you can't access the browser directly, you have to configure everything via Firefox's config files, which can take some time to figure out.
Useful links to help you get started:
http://semicomplete.com/blog/geekery/xvfb-firefox.html
http://www.webmasterworld.com/forum21/9182.htm