onlineuniconverter/onlineuniconverter-laravel

Laravel PHP SDK for OnlineUniConverter APIs

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

This package is auto-updated.

Last update: 2024-04-07 16:39:47 UTC


README

This is the official Laravel package for the OnlineUniConverter API v2

Tests Latest Stable Version Total Downloads Latest Unstable Version License

Installation

You can install the package via composer:

composer require onlineuniconverter/onlineuniconverter-laravel

This package requires a HTTP client. It works both with Guzzle 6 and 7. If you are using Guzzle 6, you need an adapter:

composer require php-http/guzzle6-adapter

Guzzle 7 works out of the box.

Next you must publish the config file.

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

This is the content that will be published to config/onlineuniconverter.php:

Usage

File conversion

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

Remote files

It will also work with converting remote files (just make sure you provide a path to save it to)

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

You can use the OnlineUniConverter to see the available options for the various task types.

Tests

vendor/bin/phpunit 

Resources