承接 carboneio/carbone-sdk-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

carboneio/carbone-sdk-php

Composer 安装命令:

composer require carboneio/carbone-sdk-php

包简介

Official Carboneio PHP SDK to generate documents through the Carbone CLOUD API.

README 文档

README

This package provides a PHP SDK for the Carbone.io Cloud API.

Cover

About Carbone

Carbone is a powerful and easy to use API to generate documents from a template to a PDF. It is based on LibreOffice and can convert any document supported by LibreOffice. It is also possible to convert HTML to PDF. Learn more about supported files and features.

Installation

You can install the bindings via Composer. Run the following command:

composer require carboneio/carbone-sdk-php

Usage

Carbone instance

Using the SDK is very easy. You just need to create a new instance of the Carbone class and provide your API key. Get your API key on your Carbone account: https://account.carbone.io/.

use Carboneio\SDK\Carbone;

$carbone = new Carbone('YOUR_API_KEY', 'https://api.carbone.io/');

Upload a template

You can upload a template to Carbone using the upload method. This method takes the content of the template as base64. The method returns a template ID used to generate documents.

$response = $carbone->templates()->upload($contentBase64);

$templateId = $response->getTemplateId();

Example to upload a template

Render a template

You can generate a document using the render method. This method takes the template Id and the data as parameters. A render ID is returned and must be used to download the generated document.

$response = $carbone->renders()->render($templateId, $data);

$renderId = $response->getRenderId();

Example to render a template

Download a rendered template

You can download a rendered template using the download method. This method takes the render ID as a parameter.

$response = $carbone->renders()->download($renderId);

// Save the contents of the file yourself on your filesystem
$content = $response->getContent();

Example to download a rendered document

Delete a template

You can delete a template using the delete method. This method takes the template Id as a parameter.

$response = $carbone->templates()->delete($templateId);

Example to delete a template

Download a template

You can download a template using the download method. This method takes the template Id as a parameter.

$response = $carbone->templates()->download($templateId);

Example to download a template

Add custom headers

Set custom headers, such as "carbone-version" to select a specific Carbone version. By default, the SDK request the version 4 of Carbone.

$carbone->headers()->set([
  "carbone-version" => 4,
  /** Uncomment to delete automatically templates after a specific time */
  // "carbone-template-delete-after" => 86400, // 86400s = 1 day | https://carbone.io/api-reference.html#template-storage
  // "carbone-webhook-url" => "https://my-server", // https://carbone.io/api-reference.html#api-webhook
]);

Get API Status

$response = $carbone->getStatus();
$json = $response->json();

echo "Status : " . $response->status() . "\n";
echo "Success: " . $json['success'] . "\n";
echo "Version: " . $json['version'] . "\n";
echo "Message: " . $json['message'] . "\n";

🧪 Run tests

First install required composer packages:

composer install

Then execute tests:

composer test

👤 History

The package was originaly made by MadeByBob and open-sourced the code. The Carbone.io team is now maintaining the SDK and will bring all futur evolutions.
Original repository:https://github.com/madebybob/carbone-sdk
MadeByBob website: https://madebybob.nl/

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

carboneio/carbone-sdk-php 适用场景与选型建议

carboneio/carbone-sdk-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 203.38k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2023 年 01 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 203.38k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 12
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-13