定制 safermobility/laravel-gotenberg 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

safermobility/laravel-gotenberg

最新稳定版本:v1.0.2

Composer 安装命令:

composer require safermobility/laravel-gotenberg

包简介

Create PDFs in Laravel apps using Gotenberg

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides a simple way to create PDFs in Laravel apps. Under the hood it uses Gotenberg to generate PDFs from Blade views. You can use modern CSS features like grid and flexbox to create beautiful PDFs.

This package is very heavily based on Spatie's laravel-pdf package, but does not require Node.js to run, making it more suitable for applications that run in containers.

Installation

You can install the package via composer:

composer require safermobility/laravel-gotenberg

You can publish the config file with:

php artisan vendor:publish --tag="gotenberg-config"

This is the contents of the published config file:

return [ 'host' => env('GOTENBERG_HOST'), ];

Usage

You must have a working Gotenberg instance.

For development, you may be able to use the Gotenberg Demo server:

GOTENBERG_HOST=https://demo.gotenberg.dev

For production, you must set up your own Gotenberg instance.

Simple PDF generation

use SaferMobility\LaravelGotenberg\Facades\Gotenberg; Gotenberg::view('pdfs.invoice', ['invoice' => $invoice]) ->format('letter') ->save('invoice.pdf')

This will render the Blade view pdfs.invoice with the given data and save it as a PDF file.

You can also return the PDF as a response from your controller:

use SaferMobility\LaravelGotenberg\Facades\Gotenberg; class DownloadInvoiceController { public function __invoke(Invoice $invoice) { return Gotenberg::view('pdfs.invoice', ['invoice' => $invoice]) ->format('letter') ->name('your-invoice.pdf'); } }

This will use a streamed response to reduce memory usage.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固