traincase/laravel-pdf-tinker
Composer 安装命令:
composer require traincase/laravel-pdf-tinker
包简介
Live tinkering with HTML templates for conversion to PDF.
README 文档
README
This package is meant as a tool for local development. Do not include this package in your production build.
Laravel PDF Tinker gives you a quick interface to debug and fiddle with the creation of HTML templates that will be converted into PDF's.
If you're one of those guys that frequently has to create custom templates for every client (order confirmations, goods deliveries, invoices etc.) this package is for you.
Installation
Since this package is only meant for during local development install this package as a development dependency.
composer require traincase/laravel-pdf-tinker --dev
The package will automatically register it's service provider, if you opted out of auto-discovery add something along the lines of the following to a registered service provider (for example the AppServiceProvider):
// Put this inside the 'register' method if ($this->app->isLocal()) { $this->register(\Traincase\LaravelPdfTinker\PdfTinkerServiceProvider::class); }
Don't forget to check the drivers section to see if the driver you're planning to use requires any additional set-up.
Usage
You can find most options straight in the interface of the playground. Chances are high you don't have to edit the configuration. Nevertheless, there are a few things you can configure.
Configuration
Route prefix
The service provider will register a few routes necessary to set up and run the playground.
By default the routes are all prefixed with vendor/laravel-pdf-tinker.
This means the playground is available at your-app.tld/vendor/laravel-pdf-tinker/playground.
Do you have an unlikely collision with your routes? No worries!
You may publish the configuration file (php artisan vendor:publish) and edit the route_prefix key in config/laravel-pdf-tinker.php to use a different prefix of your liking.
Driver options
If you published the configuration file you can also update the default_driver_options.<your-driver-alias> key to set the default options that will be set in the interface (under Configuration > Options).
This will just be used when you enter the playground, you can always update the configuration inside the playground.
Any changes will not be persisted once you leave the page, so if you tinker a lot you might want to override the default options.
Drivers
Currently there are two drivers available.
DomPDF
DomPdf is the easiest driver to get started. Everything should already be in place after following the installation instructions.
Happy tinkering!
Wkhtmltopdf
The wkhtmltopdf driver needs the wkhtmltopdf executable to be available in your PATH.
This means that if you run wkhtmltopdf --version in a terminal it should output something like the following:
$ wkhtmltopdf --version wkhtmltopdf 0.12.5 (with patched qt)
If you're using mac&homebrew you can run brew cask install wkhtmltopdf.
On any other system download the binaries for your system from the wkhtmltopdf website.
Creating your own drivers
It's possible to create a driver of the HTML2PDF generation library of your choice. Simply create your driver and register it with the PdfTinkerManager.
- First things first, this is the time to create your driver. Your driver should extend
\Traincase\HtmlToPdfTinker\Drivers\Driver. You can take an example fromTraincase\LaravelPdfTinker\DompdfDriver. - Register it with the
PdfTinkerManager. Add the following lines to one of your registered service providers in thebootmethod.public function boot() { if ($this->app->isLocal()) { $this->app->resolving(\Traincase\HtmlToPdfTinker\PdfTinkerManager::class, function($manager) { $manager->extend('test-driver', function() { // Need to fetch some things from the container? Sure. $dependency = $this->app->make(\SomeFancyClass::class); return new \App\Drivers\YourFancyDriver($dependency); }); }); } }
- Your driver will automatically show up in the interface in the drivers dropdown, you're free to tinker!
Ready, set...
If you followed all the installation instructions go ahead and tinker away! Open up your browser and navigate to your-app.tld/vendor/laravel-pdf-tinker/playground.
traincase/laravel-pdf-tinker 适用场景与选型建议
traincase/laravel-pdf-tinker 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 30 次下载、GitHub Stars 达 44, 最近一次更新时间为 2020 年 02 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「pdf」 「html」 「laravel」 「html2pdf」 「preview」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 traincase/laravel-pdf-tinker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 traincase/laravel-pdf-tinker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 traincase/laravel-pdf-tinker 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
HTML and form generation
A modern HTML DOM parser for PHP using DOMDocument and Symfony CssSelector.
Reusable utilities library for Lacus Solutions' packages (type description, HTML escaping, random sequences)
Provides TCPDF integration for Symfony
Yii2 block extension
统计信息
- 总下载量: 30
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 44
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-26
