pwaldhauer/browsershot-aio 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pwaldhauer/browsershot-aio

最新稳定版本:v0.1

Composer 安装命令:

composer require pwaldhauer/browsershot-aio

包简介

All in one Docker Container to run Browsershot

README 文档

README

This is a combinaton of two things:

  • A Docker image based on alpine-chrome including a simple Express server that executes the command generated by the Browsershot library by Spatie
  • A simple PHP wrapper that extends the original Browsershot library with the code to call the Express server instead of using node to call Puppeteer

Why?

  • I do not want to include Node and Puppeteer in my main PHP application image
  • I do not want to mess with all the hassle of using remoteInstance
  • I do not want to use Lambda functions using the wonderful sidecar-browsershot library (Instead I was heavily influenced by it.)

Caution

It may very well be that half of the functions of Browsershot do not work. I just tested simple pdf generation. Also the Express server has no authentication. I won't recommend using this in a production environment.

Running

For more information please see the README of alpine-chrome

docker container run -p 3000:3000 -it --rm --cap-add=SYS_ADMIN ghcr.io/pwaldhauer/browsershot-aio

Or use something like that in a docker-compose.yml:

  chrome:
    image: ghcr.io/pwaldhauer/browsershot-aio
    restart: unless-stopped
    cap_add:
      - SYS_ADMIN

Using in PHP

Use it like you would use Browsershot but replace it with BrowsershotAio. Be sure to set the url to the express server:

use pwaio\BrowsershotAio\BrowsershotAio;

BrowsershotAio::setEndpoint('http://chrome:3000');

// if you do not want to create a shared volume for your containers
$data = BrowsershotAio::url('https://example.com')->base64Screenshot();

// an image will be saved (needs a shared volume)
BrowsershotAio::url('https://example.com')->save($pathToImage);

// a pdf will be saved (needs a shared volume)
BrowsershotAio::url('https://example.com')->save('example.pdf');

License

MIT

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 2
  • Forks: 1
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-08