定制 markocupic/cloudconvert-bundle 二次开发

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

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

markocupic/cloudconvert-bundle

Composer 安装命令:

composer require markocupic/cloudconvert-bundle

包简介

This Bundle for the Contao CMS provides a OOP PHP wrapper for CloudConvert's API. Convert files from one filetype into an other with ease.

README 文档

README

Cloudconvert Bundle

This simple bundle for the Contao CMS provides an OOP PHP wrapper for converting files from one format into another using the Cloudconvert API.

Almost everything is possible:

  • docx -> pdf
  • jpeg -> png
  • wav -> mp3
  • csv -> xlsx
  • etc. For a full list of formats visit Cloudconvert.

Free plan (25 credits per day)

Get your free API key for using the Cloudconvert API: Free Plan Cloudconvert

Installation & configuration

Install the extension via the Contao Manager or call composer require markocupic/cloudconvert-bundle in your command line.

In your config/config.yaml you now have to set the api key.

# config/config.yaml
markocupic_cloudconvert:
  api_key: '****' # is mandatory
  sandbox_api_key: '****' # is optional
  backend_alert_credit_limit: 100 # is optional /default to: 200 /set to 0 to disable the system alert
  credit_expiration_notification: # is optional
      enabled: true # is optional
      limit: 150 # is optional
      email: ['foo@bar.ch', 'bar@foo.ch'] # is optional

To complete the installation please run composer install in your command line.

Usage

<?php

declare(strict_types=1);

namespace App\Controller;

use Contao\CoreBundle\Framework\ContaoFramework;
use Contao\System;
use Markocupic\CloudconvertBundle\Conversion\ConvertFile;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\Routing\Annotation\Route;

#[Route('/cloudconvert_demo', name: CloudconvertDemoController::class, defaults: ['_scope' => 'frontend'])]
class CloudconvertDemoController extends AbstractController
{

    public function __construct(
        private readonly ContaoFramework $framework,
        private readonly ConvertFile $convertFile,
    ){}

    /**
     * @throws \Exception
     */
    public function __invoke(): BinaryFileResponse
    {

        $this->framework->initialize();
        $projectDir = System::getContainer()->getParameter('kernel.project_dir');

        $sourcePath = $projectDir.'/files/mswordfile.docx';

        // Basic example (minimal configuration):
        // Convert from docx to pdf
        $objSplFile = $this->convertFile
            ->file($sourcePath)
            // Save converted file in the same
            // directory as the source file.
            ->convertTo('pdf')
        ;

        $sourcePath = $projectDir.'/files/samplesound.wav';

        // Convert from wav to mp3
        $objSplFile = $this->convertFile
            ->reset()
            ->file($sourcePath)
            ->convertTo('mp3')
        ;

        $sourcePath = $projectDir.'/files/image.jpg';

        // A slightly more sophisticated example:
        $objSplFile = $this->convertFile
            ->reset()
            ->file($sourcePath)
            // Sandbox API key has to be set in config/config.yaml
            ->sandbox(true)
            ->uncached(false) // Enable cache
            ->setCacheHashCode('566TZZUUTTAGHJKUZT') // use the hash of your file to get the file from the cache directory
            // For a full list of possible options
            // please visit https://cloudconvert.com/api/v2/convert#convert-tasks
            ->setOption('width', 1200)
            ->setOption('quality', 90)
            // Convert docx file into the png format and
            // save file in a different directory.
            // For a full list of supported formats
            // please visit https://cloudconvert.com/api/v2/convert#convert-formats
            ->convertTo('png', 'files/images/my_new_image.png')
        ;

        // Send the converted file to the browser
        return $this->file($objSplFile->getRealPath());
    }
}

markocupic/cloudconvert-bundle 适用场景与选型建议

markocupic/cloudconvert-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.63k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 06 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 4.63k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 17
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2019-06-13