hamza-rico/laravel-pingen-letter 问题修复 & 功能扩展

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

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

hamza-rico/laravel-pingen-letter

Composer 安装命令:

composer require hamza-rico/laravel-pingen-letter

包简介

Turn any PDF into a Pingen-ready A4 letter (generated address cover page + A4 normalisation + safe margins) and send it through the Pingen print & mail API. Laravel-first.

README 文档

README

Turn any PDF into a Pingen-ready A4 letter and send it through the Pingen print & mail API — with a generated address cover page, automatic A4 normalisation, and safe print margins.

Pingen reads the recipient address off the first page of the PDF (the window-envelope zone) and rejects non-A4 pages or content in the protected border/postage areas. This package handles all of that for you:

  1. Draws an address cover page (recipient in the window zone).
  2. Merges cover + your documents into one file (via a pluggable driver).
  3. Re-lays every page to A4 with safe margins — Letter, legal, or compressed source PDFs all come out clean.

Then it uploads, creates and sends the letter via Pingen.

Requirements

  • PHP 8.2+
  • Laravel 10, 11 or 12
  • A Pingen account + a Developer-App (OAuth2 client_credentials)
  • A PDF merge driver — one of:
    • ConvertAPI (recommended, no server binary) — composer require convertapi/convertapi-php
    • Ghostscript (gs installed on the server)
    • FPDI (pure PHP, only for simple/uncompressed inputs)

Installation

composer require hamza-rico/laravel-pingen-letter
php artisan vendor:publish --tag=pingen-letter-config

Configuration

Add to your .env:

PINGEN_STAGING=true
PINGEN_CLIENT_ID=your-client-id
PINGEN_CLIENT_SECRET=your-client-secret
PINGEN_ORGANISATION_ID=your-organisation-uuid

# merge driver: convertapi | ghostscript | fpdi
PINGEN_MERGER=convertapi
CONVERTAPI_SECRET=your-convertapi-secret
# or, for ghostscript:
# PINGEN_MERGER=ghostscript
# PINGEN_GS_BIN=/usr/bin/gs

Pingen offers a free staging environment that mails nothing — keep PINGEN_STAGING=true until you're ready to go live.

Usage

use HamzaRico\PingenLetter\Facades\PingenLetter;
use HamzaRico\PingenLetter\DTO\Recipient;
use HamzaRico\PingenLetter\Enums\DeliveryProduct;

$letter = PingenLetter::to(new Recipient(
        name:    'Jane Doe',
        street:  'Musterstrasse 12',
        zip:     '10115',
        city:    'Berlin',
        country: 'DE',
    ))
    ->documents([
        'https://example.com/translation.pdf',
        storage_path('app/certificate.pdf'),
    ])
    ->deliveryProduct(DeliveryProduct::Cheap)
    ->color()
    ->duplex()
    ->send();

// ['id' => '…', 'url' => 'https://app.pingen.com/…', 'status' => 'sent', 'pages' => 3]

Just build the print-ready PDF (no sending)

$pdf = PingenLetter::to($recipient)
    ->documents([$path])
    ->build(); // ['path' => '/tmp/…​.pdf', 'pages' => 2]

Low-level API access

$client = PingenLetter::client();
$client->getLetter($id);       // status + tracking
$client->cancelLetter($id);    // cancel (only while submitted / print preparation)
$client->calculatePrice([...]); // price for a country + options

Page limits

Pingen enforces per-country page limits — tightest are Netherlands (14) and India (16); most others allow 120–500. Check the page count from build() before sending if you mail to those countries.

Delivery products

cheap (default), fast, bulk, premium, registered. Pingen maps these to each destination country's real postal product. Only registered provides a carrier tracking number; standard letters give status updates only.

Testing

composer install
vendor/bin/phpunit

License

MIT.

hamza-rico/laravel-pingen-letter 适用场景与选型建议

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

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

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

围绕 hamza-rico/laravel-pingen-letter 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-15