jrm2k6 / cloudder

Cloudinary wrapper for Laravel 5
MIT License
264 stars 56 forks source link
cloudinary image laravel-4-package laravel-5-package lumen

Cloudder - Cloudinary wrapper for Laravel 5 / Lumen

This project is not actively maintained. I might be slow to answer, as you can tell by looking at the issues. I have moved to some new projects, not in the PHP ecosystem. You can always reach out to me through my email.

If you fork it on publish it as your own, it might be nice to credit the original author at https://github.com/teepluss/laravel4-cloudinary.

Build Status License Latest Version Total Downloads

Initially forked from https://github.com/teepluss/laravel4-cloudinary.

If there is any feature you would like feel free to open an issue or send me an email!

Installation

composer require jrm2k6/cloudder

For people still using Laravel 4.2: composer require jrm2k6/cloudder:0.1.* and check the branch l4 for the installation instructions.

Configuration

Modify your .env file to add the following information from Cloudinary

Required

CLOUDINARY_API_KEY=012345679890123
CLOUDINARY_API_SECRET=foobarfoobarfoob-arfoobarfo
CLOUDINARY_CLOUD_NAME=foobarcorp

Optional

CLOUDINARY_BASE_URL
CLOUDINARY_SECURE_URL
CLOUDINARY_API_BASE_URL

Laravel 5.5+ uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider. If you don't use auto-discovery follow the next steps:

Add the following in config/app.php:

'providers' => array(
  JD\Cloudder\CloudderServiceProvider::class,
);

'aliases' => array(
  'Cloudder' => JD\Cloudder\Facades\Cloudder::class,
);

Run php artisan vendor:publish --provider="JD\Cloudder\CloudderServiceProvider"

Usage

upload()

Cloudder::upload($filename, $publicId, array $options, array $tags);

with:

returns the CloudinaryWrapper.

uploadVideo()

Cloudder::uploadVideo($filename, $publicId, array $options, array $tags);

with:

returns the CloudinaryWrapper.

getPublicId()

Cloudder::getPublicId()

returns the public id of the last uploaded resource.

getResult()

Cloudder::getResult()

returns the result of the last uploaded resource.

show() + secureShow()

Cloudder::show($publicId, array $options)
Cloudder::secureShow($publicId, array $options)

with:

returns the url of the picture on Cloudinary (https url if secureShow is used).

showPrivateUrl()

Cloudder::showPrivateUrl($publicId, $format, array $options)

with:

returns the private url of the picture on Cloudinary, expiring by default after an hour.

rename()

Cloudder::rename($publicId, $toPublicId, array $options)

with:

renames the original picture with the $toPublicId id parameter.

destroyImage() + delete()

Cloudder::destroyImage($publicId, array $options)
Cloudder::delete($publicId, array $options)

with:

removes image from Cloudinary.

destroyImages()

Cloudder::destroyImages(array $publicIds, array $options)

with:

removes images from Cloudinary.

addTag()

Cloudder::addTag($tag, $publicIds, array $options)

with:

removeTag()

Cloudder::removeTag($tag, $publicIds, array $options)

with:

createArchive()

Cloudder::createArchive(array $options, $archiveName, $mode)

with:

creates a zip file on Cloudinary.

downloadArchiveUrl()

Cloudder::downloadArchiveUrl(array $options, $archiveName)

with:

returns a download url for the newly created archive on Cloudinary.

Running tests

phpunit

Example

You can find a working example in the repo cloudder-l5-example