You could do 2 things.
Use Puppeteer
You can use the PHP Puppeteer package to spin up a browser and take a screenshot.
Use an API
There are a lot of screenshot APIs. You could look at ScreenshotAPI.net for example. (Disclaimer I'm the creator of that API)