承接 markocupic/cloudconvert-bundle 相关项目开发

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

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

markocupic/cloudconvert-bundle

最新稳定版本:2.5.10

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());
    }
}

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固