actengage/capture 问题修复 & 功能扩展

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

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

actengage/capture

Composer 安装命令:

composer require actengage/capture

包简介

The official SDK for Capture.

README 文档

README

This package provides fluent SDK for the Capture server. Capture is a Node server on AWS that takes screenshots with a variety of options. This package requires access to a Capture server endpoint before it be used.

Requirements

  • Laravel ^9.1
  • PHP ^8.1
  • Guzzle ^7.0
  • Capture Server Endpoint

Capture Server

Why is the Capture server endpoint not included in the package? Capture is a private Node server that runs Puppeteer with a specific set of features that are used for our internal products. We do not publish the URL, as its not intended for public consumption. You may however deploy your own Capture server and endpoint.

Capture Server

Installation

Install via Composer

composer require actengage/capture-sdk

Publish the config file

php artisan vendor:publish --tag=capture-config

Set the endpoint URL in your ENV file.

CAPTURE_ENDPOINT=http://localhost:3000/

Basic Usage

use Actengage\Capture\Facades\Screenshot;

$response = Screenshot::make('https://google.com')->request();

Calls

Call allow you to execute methods on the Puppeteer page instance before the screenshot has been taken. This is a convenient way to execute a sequence of actions that are explicitly built into the server options (mainly for edge cases). The first argument is the method name, and all other arguments are passed to the method in Puppeteer.

use Actengage\Capture\Facades\Screenshot;

$response = Screenshot::make('https://google.com')
    ->call('$', 'header#nav > .logo')
    ->request();

Clipping

Clip a portion of an image using width, height, x, and y coordinates. There is no clipping by default.

use Actengage\Capture\DataTypes\Clip;
use Actengage\Capture\Facades\Screenshot;

$response = Screenshot::make('https://google.com')
    ->clip(new Clip(800, 600, 400, 300))
    ->request();

Encoding

Encoding changes how the response is composed, either using binary or base64. Defaults to binary.

use Actengage\Capture\DataTypes\Encoding;
use Actengage\Capture\Facades\Screenshot;

$response = Screenshot::make('https://google.com')
    ->encoding(Encoding::Binary)
    ->request();

Full Page

Take full page screenshots. Defaults to false.

use Actengage\Capture\Facades\Screenshot;

$response = Screenshot::make('https://google.com')
    ->fullPage(true)
    ->request();

Headers

Pass a custom headers that are included by Puppeteer in its HTTP request. Defaults to {"Accept-Language": "en-US"}.

use Actengage\Capture\DataTypes\Encoding;
use Actengage\Capture\Facades\Screenshot;

$response = Screenshot::make('https://google.com')
    ->header('Accept-Language', 'en-US')
    ->request();

Omit Background

This omits the black background for transparent PNG images. Defaults to true.

use Actengage\Capture\Facades\Screenshot;

$response = Screenshot::make('https://google.com')
    ->omitBackground(true)
    ->request();

Quality

The quality of image that is returned. Must be 1-100. Defaults to 100.

use Actengage\Capture\Facades\Screenshot;

$response = Screenshot::make('https://google.com')
    ->quality(100)
    ->request();

Timeout

The timeout of the Puppeteer request (in milliseconds). Defaults to 25000.

use Actengage\Capture\Facades\Screenshot;

$response = Screenshot::make('https://google.com')
    ->timeout(15000)
    ->request();

Type

The type of image that is returned, jpeg or png. Defaults to jpeg.

use Actengage\Capture\DataTypes\Type;
use Actengage\Capture\Facades\Screenshot;

$response = Screenshot::make('https://google.com')
    ->type(Type::PNG)
    ->request();

Viewport

The viewport dimensions. Defaults to {"width": 1200, "height": 800}.

use Actengage\Capture\DataTypes\Viewport;
use Actengage\Capture\Facades\Screenshot;

$response = Screenshot::make('https://google.com')
    ->viewport(new Viewport(1200, 800))
    ->request();

Wait Until

How long should Puppeteer wait before returning a response. Defaults to ['load', 'networkidle2'].

use Actengage\Capture\DataTypes\WaitUntil;
use Actengage\Capture\Facades\Screenshot;

$response = Screenshot::make('https://google.com')
    ->waitUntil([WaitUntil::Load, WaitUntil::NetworkIdle2])
    ->request();

actengage/capture 适用场景与选型建议

actengage/capture 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 516 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 06 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「screenshot」 「capture」 「puppeteer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 actengage/capture 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 actengage/capture 我们能提供哪些服务?
定制开发 / 二次开发

基于 actengage/capture 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-07