Download the PHP package uploadcare/uploadcare-php without Composer

On this page you can find all versions of the php package uploadcare/uploadcare-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package uploadcare-php

Uploadcare PHP

Uploadcare PHP integration handles uploads and further operations with files by wrapping Upload and REST APIs.

Test workflow Code coverage Uploadcare stack on StackShare

Requirements

Install

Prior to installing uploadcare-php get the Composer dependency manager for PHP because it'll simplify installation.

Step 1 — update your composer.json:

Step 2 — run Composer:

Or, you can run the composer.phar require uploadcare/uploadcare-php instead of steps 1 and 2.

Step 3 — define your Uploadcare public and secret API keys in a way you prefer (e.g., by using a $_ENV variable):

Add API keys to your configuration object. For example:

Step 4 — include a standard composer autoload file:

Step 5 — create an object of the Uploadcare\Configuration class,

All further operations will use this configuration object.

Configuration object

There are a few ways to make a valid configuration object. We recommend using the static method of the class:

Alternatively, you can create a Security signature, HTTP client, and Serializer classes explicitly. Then create a configuration:

As you can see, the factory method is more convenient for standard usage.

Usage

You can find the full example in this Uploadcare example project.

First, create an API object:

Uploading files

This section describes multiple ways of uploading files to Uploadcare.

You can use the core API object for any upload type:

First of all, files can be uploaded from URL. The following code returns a token to check file upload status,

You can upload files from URL synchronically,

Check an uploading file status,

Another way of uploading files is by using a path,

It’s also relevant when using file pointers,

There's an option of uploading a file from its contents. You’ll need to specify MIME-types as well:

Secure signature. If you are using secure uploads, you can use getSignature method to fetch an instance of SignatureInterface. For example:

File metadata

Every upload method can set a file metadata. For example:

You will see this values in a metadata object of Uploadcare\File response.

Multipart upload

If you have a large file (more than 100Mb / 10485760 bytes), the uploader will automatically process it with a multipart upload. It'll take more time to upload, and also we don’t recommend it for a web environment.

Uploadcare\File class

This class implements Uploadcare\Interfaces\File\FileInfoInterface and it has additional methods (besides the interface):

All these operations are accessible via File API, and you can access them through the Uploadcare\File object as well.

File operations

For any file operation type, you’ll need to create an Uploadcare\Api instance with configuration object and call the file() method:

After that, you can access to file operation methods:

See the API documentation for more details.

Uploadcare\FileCollection class

This class implements Uploadcare\Interfaces\File\CollectionInterface and has additional methods besides the interface:

Each file in the collection is an object of the Uploadcare\File class.

Uploadcare\File class

This class implements FileInfoInterface and has additional methods for file operations:

As you can see, additional methods help you to call API methods without direct API calls.

Addons operations

Uploadcare provide a few additional operations with images.

Object Recognition

To call object recognition from library:

Unsafe content detection

To call unsafe content detection from the library:

Remove background

Remove background from image:

Antivirus scan

Group operations

For any type of group operation you need to create an Uploadcare\Api instance with a configuration object and call the group() method:

After that, you can access group operation methods:

Uploadcare\Group class

This class implements Uploadcare\Interfaces\GroupInterface.
The getFiles() method of the Uploadcare\Group object returns FileCollection.

Project operations

As usual, Project API is accessible by the main API object:

You can get the project information by calling the getProjectInfo method:

Now, the $projectInfo variable contains the Uploadcare\Interfaces\Response\ProjectInfoInterface implementation with the following methods:

Webhooks

Call the webhook API:

The methods are:

Uploadcare\Webhook class

This class implements Uploadcare\Interfaces\Response\WebhookInterface and has additional methods besides the interface:

Conversion operations

You can convert documents, images and encode video files with Conversion API.

Document and image conversion

Create a new object for a subsequent conversion request:

The default arguments and examples are:

After that, you can convert your file:

Result will contain one of two objects:

The ConvertedItemInterface will contain a UUID of converted document and token with conversion job ID. You can request the conversion job status with this ID (or the ConvertedItemInterface object itself):

You can also pass the true to the setSaveInGroup method to the Request object.

In this case, the result of the document conversion will be stored in a group. See further details here.

This status object will implement ConversionStatusInterface with these methods:

You can request batch conversion to process multiple documents:

$files can be an array / collection of file IDs or FileInfo objects and the result will be the implementation of BatchResponseInterface.

Video processing

Get the conversion API as in the previous step and perform VideoEncodingRequest

You can set various parameters for this request through the object setters:

If you don’t set any option to conversion request, the defaults will be as follows: mp4 format, full length and normal quality.

As a result of the Conversion API convertVideo method, you will get the ConversionResult or ResponseProblemobject. ConversionResult object that contains the uuid and token. You can use a token to request the status of a video conversion job with videoJobStatus method.

Also, you can request a batch video conversion with batchConvertVideo method. The first argument must be a collection of FileInfo or file uuid's, and the second — VideoEncodingRequest object.

Secure delivery

You can use your own custom domain and CDN provider for deliver files with authenticated URLs (see original documentation).

To generate authenticated URL from the library, you should do this:

For example:

Secure delivery for transformed images

You can set a custom ACL on a Secure URL with Image Transformations applied. Just add an Image UUID with transformations to the generateSecureUrl method:


Tests

PHP 7.1+ tests can be found in the "tests" directory. All tests are based on PHPUnit, so you need to have it installed prior to running tests.

Run tests with this command:

--exclude-group local-only means that a test will not send real API-requests. If you want to run all tests, create the .env.local file in the tests directory and place the following variables with your real public and secret API keys:

Useful links

Uploadcare documentation
Upload API reference
REST API reference
Changelog
Contributing guide
Security policy
Support


All versions of uploadcare-php with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4 || >=8.0
ext-curl Version *
ext-json Version *
guzzlehttp/guzzle Version ^7.5
guzzlehttp/psr7 Version ^2.4
symfony/polyfill-php80 Version ^1.26
symfony/polyfill-uuid Version ^1.26
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package uploadcare/uploadcare-php contains the following files

Loading the files please wait ....