Today, there are many options to make screenshots of any URL with PHP:
- Selenium WebDriver client for PHP.
- You can use the PHP analog of Puppeteer.
- Or Screenshot API as a service.
They might overlap, but there is no best solution. Each depends on your use case and requirements.
Selenium WebDriver client for PHP
Selenium is a well-known kid in the QA automation area, so it is easy to start taking screenshots if you plan to write automation tests or already do it.
Install Selenium WebDriver client for PHP into your project:
Download the latest version ChromeDriver, run it:
And you are ready to use it:
If you just want to take one or two screenshots locally, the Selenium WebDriver client is not the best fit. As I wrote earlier, it better serves you already write automation tests with Selenium or plan to write them.
PHP analog of Puppeteer
PuPHPeteer is the closest analog to Node.js Puppeteer in PHP, a faster, more straightforward way to drive browsers supporting the Chrome DevTools Protocol in PHP.
While you can also use PuPHPeteer
for automation testing, it is much light weighter and simpler than Selenium and allows any automation over the browser. Everything you can do manually with a browser, you can also do with PuPHPeteer
.
And it is super easy to use:
And then just:
It is very lightweight compared to Selenium and allows a broad spectrum for automation of the browser. You can use it for crawling, scrapping, taking screenshots, etc.
If you need the simplest way to take screenshots, you do not expect to take millions of them, and I would go with PuPHPeteer
. But if you want to take screenshots from different browsers or think about managing instances of browsers, there is a more straightforward way to go.
Screenshot API as a service
We specialize in taking screenshots and managing browser instances at scale. We provide a high-quality PHP client to take screenshots and cover a variety of use cases.
Easy to install:
And easy to use:
If you feel that it is the best fit for you, feel free to sign up for our screenshot API and get the access key.
Summary
Pick the solution which suits your needs best. If you decide to go with our API, please ask any questions and mail us at support@screenshotone.com. And have a nice day 👋
By the way, you might also find interesting how to: