toolcenter/sdk 问题修复 & 功能扩展

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

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

toolcenter/sdk

Composer 安装命令:

composer require toolcenter/sdk

包简介

Official PHP SDK for ToolCenter API - Web automation tools including screenshots, PDFs, QR codes, metadata extraction, and more.

README 文档

README

Latest Stable Version PHP Version Require License Total Downloads

The official PHP SDK for ToolCenter - A comprehensive API for web automation tools including screenshots, PDFs, QR codes, metadata extraction, and much more.

Features

  • 🖼️ Screenshots - Capture high-quality screenshots of any website
  • 📄 PDF Generation - Convert web pages to PDF documents
  • 🔗 QR Codes - Generate customizable QR codes
  • 📊 Metadata Extraction - Extract rich metadata from websites
  • 🎨 Image Processing - Watermarks, compression, and color extraction
  • 🔍 Website Analysis - DNS, SSL, WHOIS, and tech stack detection
  • 📱 Social Media - Open Graph images and link previews
  • 🚀 Bulk Operations - Process multiple URLs efficiently

Installation

Install the SDK via Composer:

composer require toolcenter/sdk

Quick Start

<?php

require_once 'vendor/autoload.php';

use ToolCenter\ToolCenter;

// Initialize the client with your API key
$tc = new ToolCenter('your-api-key-here');

// Capture a screenshot
$screenshot = $tc->screenshot([
    'url' => 'https://example.com',
    'width' => 1920,
    'height' => 1080,
    'format' => 'png'
]);

echo "Screenshot URL: " . $screenshot['url'] . "\n";

Authentication

Get your API key from your ToolCenter Dashboard and initialize the client:

$tc = new ToolCenter('your-api-key-here');

// Or with a custom base URL
$tc = new ToolCenter('your-api-key-here', 'https://custom.toolcenter.dev');

Usage Examples

Screenshots

// Basic screenshot
$result = $tc->screenshot([
    'url' => 'https://example.com'
]);

// Full page screenshot with custom dimensions
$result = $tc->screenshot([
    'url' => 'https://example.com',
    'width' => 1920,
    'height' => 1080,
    'fullPage' => true,
    'format' => 'webp',
    'quality' => 90
]);

PDF Generation

// Generate PDF
$result = $tc->pdf([
    'url' => 'https://example.com',
    'format' => 'A4',
    'orientation' => 'portrait',
    'margin' => '1cm'
]);

// PDF with custom options
$result = $tc->pdf([
    'url' => 'https://example.com',
    'format' => 'letter',
    'landscape' => true,
    'printBackground' => true,
    'scale' => 0.8
]);

QR Codes

// Simple QR code
$result = $tc->qr([
    'data' => 'https://toolcenter.dev',
    'size' => 300
]);

// Customized QR code
$result = $tc->qr([
    'data' => 'Hello World!',
    'size' => 500,
    'format' => 'svg',
    'errorCorrection' => 'M',
    'margin' => 4
]);

Metadata Extraction

// Extract website metadata
$result = $tc->metadata([
    'url' => 'https://example.com'
]);

// Include images and social media data
$result = $tc->metadata([
    'url' => 'https://example.com',
    'includeImages' => true,
    'includeSocial' => true
]);

Bulk Operations

// Bulk screenshots
$urls = [
    'https://example.com',
    'https://google.com',
    'https://github.com'
];

$results = $tc->bulkScreenshot($urls);

// Bulk PDFs
$results = $tc->bulkPdf($urls);

// Bulk metadata
$results = $tc->bulkMetadata($urls);

Laravel Integration

Service Provider

Create a service provider to register the ToolCenter client:

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use ToolCenter\ToolCenter;

class ToolCenterServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->singleton(ToolCenter::class, function ($app) {
            return new ToolCenter(config('services.toolcenter.api_key'));
        });
    }
}

Configuration

Add your API key to config/services.php:

'toolcenter' => [
    'api_key' => env('TOOLCENTER_API_KEY'),
],

Usage in Laravel

<?php

namespace App\Http\Controllers;

use ToolCenter\ToolCenter;

class ScreenshotController extends Controller
{
    public function __construct(private ToolCenter $toolCenter)
    {
    }

    public function capture(Request $request)
    {
        $screenshot = $this->toolCenter->screenshot([
            'url' => $request->input('url'),
            'width' => 1920,
            'height' => 1080
        ]);

        return response()->json($screenshot);
    }
}

API Methods

Core Methods

Method Description Endpoint
screenshot(array $options) Capture website screenshots POST /api/v1/screenshot
pdf(array $options) Generate PDFs from web pages POST /api/v1/pdf
qr(array $options) Generate QR codes POST /api/v1/qr
ogImage(array $options) Create Open Graph images POST /api/v1/og-image
metadata(array $options) Extract website metadata POST /api/v1/metadata
htmlToImage(array $options) Convert HTML to image POST /api/v1/html-to-image
linkPreview(array $options) Generate link previews POST /api/v1/link-preview

Image Processing

Method Description Endpoint
watermark(array $options) Add watermarks to images POST /api/v1/watermark
compress(array $options) Compress images POST /api/v1/compress
colors(array $options) Extract dominant colors POST /api/v1/colors
placeholder(array $options) Generate placeholder images POST /api/v1/placeholder

Website Analysis

Method Description Endpoint
dns(array $options) DNS lookups POST /api/v1/dns
ssl(array $options) SSL certificate info POST /api/v1/ssl
status(array $options) Website status checks POST /api/v1/status
techStack(array $options) Technology stack detection POST /api/v1/techstack
whois(array $options) WHOIS lookups POST /api/v1/whois
favicon(array $options) Extract favicons POST /api/v1/favicon

Utility Methods

Method Description Endpoint
usage() Get API usage statistics GET /api/v1/usage

Bulk Operations

Method Description Endpoint
bulkScreenshot(array $urls) Bulk screenshot capture POST /api/v1/bulk/screenshot
bulkPdf(array $urls) Bulk PDF generation POST /api/v1/bulk/pdf
bulkMetadata(array $urls) Bulk metadata extraction POST /api/v1/bulk/metadata

Error Handling

The SDK provides custom exception classes for different error scenarios:

use ToolCenter\Exceptions\ToolCenterException;
use ToolCenter\Exceptions\AuthenticationException;
use ToolCenter\Exceptions\RateLimitException;

try {
    $result = $tc->screenshot(['url' => 'https://example.com']);
} catch (AuthenticationException $e) {
    // Handle authentication errors (401)
    echo "Authentication failed: " . $e->getMessage();
} catch (RateLimitException $e) {
    // Handle rate limit errors (429)
    echo "Rate limit exceeded: " . $e->getMessage();
} catch (ToolCenterException $e) {
    // Handle other API errors
    echo "API error: " . $e->getMessage();
    
    // Get the full response for debugging
    $response = $e->getResponse();
    print_r($response);
}

Requirements

  • PHP 8.1 or higher
  • Guzzle HTTP client (automatically installed via Composer)

Support

Contributing

We welcome contributions! Please feel free to submit a Pull Request.

License

This SDK is open-sourced software licensed under the MIT license.

Made with ❤️ by ToolCenter

toolcenter/sdk 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-25