定制 convertapi/convertapi-php 二次开发

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

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

convertapi/convertapi-php

Composer 安装命令:

composer require convertapi/convertapi-php

包简介

Convert API PHP Client

README 文档

README

PHP version Build Status

Convert your files with our online file conversion API

ConvertAPI helps in converting various file formats. Creating PDF and Images from various sources like Word, Excel, Powerpoint, images, web pages or raw HTML codes. Merge, Encrypt, Split, Repair and Decrypt PDF files and many other file manipulations. You can integrate it into your application in just a few minutes and use it easily.

Requirements

PHP 8.1.0 and later.

Installation

The preferred method is via composer. Follow the installation instructions if you do not already have composer installed.

Once composer is installed, execute the following command in your project root to install this library:

composer require convertapi/convertapi-php

Manual Installation

If you do not wish to use the Composer, you must require ConvertApi autoloader:

require_once('/path/to/convertapi-php/lib/ConvertApi/autoload.php');

Dependencies

Library requires the following extensions in order to work properly:

If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.

Usage

Configuration

You can get your API credentials at https://www.convertapi.com/a

use \ConvertApi\ConvertApi;

ConvertApi::setApiCredentials('your-api-secret-or-token');

File conversion

Convert file to PDF example. All supported formats and options can be found here.

$result = ConvertApi::convert('pdf', ['File' => '/path/to/my_file.docx']);

# save to file
$result->getFile()->save('/path/to/save/file.pdf');

# get file contents (without saving the file locally)
$contents = $result->getFile()->getContents();

Other result operations:

# save all result files to folder
$result->saveFiles('/path/to/save/files');

# get conversion cost
$cost = $result->getConversionCost();

Convert file url

$result = ConvertApi::convert('pdf', ['File' => 'https://website/my_file.docx']);

Specifying from format

$result = ConvertApi::convert(
    'pdf',
    ['File' => '/path/to/my_file'],
    'docx'
);

Additional conversion parameters

ConvertAPI accepts additional conversion parameters depending on selected formats. All conversion parameters and explanations can be found here.

$result = ConvertApi::convert(
    'pdf',
    [
        'File' => '/path/to/my_file.docx',
        'PageRange' => '1-10',
        'PdfResolution' => '150',
    ]
);

User information

You can always check your usage by fetching user information.

$info = ConvertApi::getUser();

echo $info['ConversionsConsumed'];

Alternative domain

Use setApiBase method to set alternative service domain. Dedicated to the region domain list.

ConvertApi::setApiBase('https://eu-v2.convertapi.com/');

More examples

Find more advanced examples in the examples/ folder.

Development

Testing is done with PHPUnit:

CONVERT_API_SECRET=your-api-secret ./bin/phpunit

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ConvertAPI/convertapi-php. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

ConvertAPI PHP Client is available as open source under the terms of the MIT License.

convertapi/convertapi-php 适用场景与选型建议

convertapi/convertapi-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.21M 次下载、GitHub Stars 达 52, 最近一次更新时间为 2018 年 06 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 52
  • Watchers: 3
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-06-23