承接 devture/browserless 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

devture/browserless

最新稳定版本:2.0.1

Composer 安装命令:

composer require devture/browserless

包简介

Library for communicating with the Browserless.io API (generating PDFs, etc.)

README 文档

README

This is a library for interacting with the Browserless.io APIs.

For the time being, this library only supports these APIs:

  • /pdf - for generating PDFs from a URL or inline HTML (like wkhtmltopdf, but better -- more up-to-date browser engine, etc.)

Prerequisites

You either need to use your own self-hosted Browserless instance (see how to do it with Docker) or their hosted offering (see Pricing).

You could use the following compose.yml setup:

version: '2.1' services: browserless: image: ghcr.io/browserless/chromium:v2.23.0 restart: unless-stopped # Matches the owner (`blessuser:blessuser`) of `/usr/src/app` user: 999:999 environment: CONCURRENT: 10 TOKEN: SOME_TOKEN_HERE # Not exposing the port is recommended, if PHP is running in a container alongisde this one ports: - "127.0.0.1:3000:3000" tmpfs: - /tmp

Usage

Creating a Browserless API client

$browserlessApiUrl = 'http://localhost:3000'; // Or 'http://browserless:3000', etc. $browserlessToken = 'SOME_TOKEN_HERE'; $browserlessTimeoutSeconds = 15; $client = new \Devture\Component\Browserless\Client( new \GuzzleHttp\Client(), $browserlessApiUrl, $browserlessToken, $browserlessTimeoutSeconds, );

Generating a PDF from a URL

$url = 'https://devture.com'; $pdfCreationRequest = new \Devture\Component\Browserless\Model\PdfCreationRequest(); $pdfCreationRequest->setUrl($url); $pdfCreationRequest->setOptions([ 'printBackground' => true, 'format' => 'A4', 'landscape' => true, ]); $pdfBytes = $client->createPdfFromRequest($pdfCreationRequest);

Generating a PDF from inline HTML

$html = '<html><body>Some <strong>HTML</strong> here</body></html>'; $pdfCreationRequest = new \Devture\Component\Browserless\Model\PdfCreationRequest(); $pdfCreationRequest->setHtml($html); $pdfCreationRequest->setOptions([ 'printBackground' => true, 'format' => 'A4', 'margin' => [ 'top' => '20mm', 'bottom' => '10mm', 'left' => '10mm', 'right' => '10mm', ], ]); $pdfBytes = $client->createPdfFromRequest($pdfCreationRequest);

Alternatives

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固