onlineuniconverter/onlineuniconverter-laravel

OnlineUniConverter APIs 的 Laravel PHP SDK

v2.0.0 2021-06-07 09:54 UTC

This package is auto-updated.

Last update: 2024-09-07 17:32:58 UTC


README

这是 OnlineUniConverter API v2 的官方 Laravel 包

Tests Latest Stable Version Total Downloads Latest Unstable Version License

安装

您可以通过 composer 安装此包

composer require onlineuniconverter/onlineuniconverter-laravel

此包需要一个 HTTP 客户端。它既支持 Guzzle 6 也支持 Guzzle 7。如果您使用的是 Guzzle 6,则需要一个适配器

composer require php-http/guzzle6-adapter

Guzzle 7 不需要任何配置即可使用。

接下来,您必须发布配置文件。

php artisan vendor:publish --provider="OnlineUniConverter\Laravel\Providers\OnlineUniConverterServiceProvider"

以下内容将被发布到 config/onlineuniconverter.php

用法

文件转换

# Init Convert Class

$onlineUniConverter = new \OnlineUniConverter\Laravel\OnlineUniConverter(config('onlineuniconverter'));
# Convert the file to /a/path/to/file.mp4

$onlineUniConverter->from('/a/path/to/file.mov')->to('mp4')->convert();
# Convert the file and save it in a different location /a/new/path/to/new.mp4

$onlineUniConverter->from('/a/path/to/biggles.webm')->to('/a/new/path/to/new.mp4')->convert();
# It also works with Laravel's file upload

if (Input::hasFile('photo'))
{
    $onlineUniConverter->from( Input::file('photo') )->to('/a/local/path/profile_image.jpg')->convert();
}
# Compress the image to kitty.jpg with ratio of 70%

$onlineUniConverter->from('kitty.png')->ratio(0.7)->to('jpg')->compress();

远程文件

它还可以用于转换远程文件(只需确保您提供了保存文件的路径即可)

# Convert Google's SVG logo hosted on Wikipedia to a png on your server

$onlineUniConverter->from('http://upload.wikimedia.org/wikipedia/commons/a/aa/Logo_Google_2013_Official.svg')->to('images/google.png')->convert();

您可以使用 OnlineUniConverter 来查看各种任务类型的可用选项。

测试

vendor/bin/phpunit 

资源