{"id":22632463,"url":"https://github.com/uploadcare/uploadcare-php","last_synced_at":"2025-04-04T08:05:44.141Z","repository":{"id":5663925,"uuid":"6873307","full_name":"uploadcare/uploadcare-php","owner":"uploadcare","description":"PHP API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.","archived":false,"fork":false,"pushed_at":"2023-11-09T20:57:29.000Z","size":3489,"stargazers_count":102,"open_issues_count":4,"forks_count":47,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-28T07:03:57.691Z","etag":null,"topics":["api","client","file-upload","image-processing","image-recognition","image-upload","php","processing","sdk","upload","uploadcare","uploader"],"latest_commit_sha":null,"homepage":"https://uploadcare.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uploadcare.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-11-26T22:03:21.000Z","updated_at":"2025-02-04T23:09:00.000Z","dependencies_parsed_at":"2023-01-13T13:39:04.215Z","dependency_job_id":"6907467b-d5e4-42c7-b749-cbdb7615d943","html_url":"https://github.com/uploadcare/uploadcare-php","commit_stats":{"total_commits":577,"total_committers":41,"mean_commits":"14.073170731707316","dds":0.830155979202773,"last_synced_commit":"e6339405066b8a85d00c49faec9556b5641beb33"},"previous_names":[],"tags_count":56,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uploadcare%2Fuploadcare-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uploadcare%2Fuploadcare-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uploadcare%2Fuploadcare-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uploadcare%2Fuploadcare-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uploadcare","download_url":"https://codeload.github.com/uploadcare/uploadcare-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247139858,"owners_count":20890303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","client","file-upload","image-processing","image-recognition","image-upload","php","processing","sdk","upload","uploadcare","uploader"],"created_at":"2024-12-09T02:17:40.528Z","updated_at":"2025-04-04T08:05:44.115Z","avatar_url":"https://github.com/uploadcare.png","language":"PHP","readme":"# Uploadcare PHP\n\nUploadcare PHP integration handles uploads and further operations with files by wrapping Upload and REST APIs.\n\n![Test workflow][action-img] ![Code coverage][codecov-img] [![Uploadcare stack on StackShare][stack-img]][stack]\n\n[action-img]: https://github.com/uploadcare/uploadcare-php/actions/workflows/phpunit.yml/badge.svg\n[stack-img]: http://img.shields.io/badge/tech-stack-0690fa.svg?style=flat\n[stack]: https://stackshare.io/uploadcare/stacks/\n[codecov-img]: https://codecov.io/gh/uploadcare/uploadcare-php/branch/master/graph/badge.svg\n\n* [Requirements](#requirements)\n* [Install](#install)\n* [Usage](#usage)\n  * [Uploading files](#uploading-files)\n  * [File operations](#file-operations)\n  * [Addons operations](#addons-operations)\n  * [Group operations](#group-operations)\n  * [Project operations](#project-operations)\n  * [Webhooks](#webhooks)\n  * [Conversion operations](#conversion-operations)\n  * [Secure delivery](#secure-delivery)\n  * [Tests](#tests)\n* [Useful links](#useful-links)\n\n## Requirements\n\n- `php7.4+` or `php8.0+`\n- `php-curl`\n- `php-json`\n\n## Install\n\nPrior to installing `uploadcare-php` get the [Composer](https://getcomposer.org) dependency manager for PHP because it'll simplify installation.\n\n**Step 1** — update your `composer.json`:\n\n```json\n\"require\": {\n    \"uploadcare/uploadcare-php\": \"^4.0\"\n}\n```\n\n**Step 2** — run [Composer](https://getcomposer.org):\n\n```bash\nphp composer.phar update\n```\n\nOr, you can run the `composer.phar require uploadcare/uploadcare-php` instead of steps 1 and 2.\n\n**Step 3** — define your Uploadcare public and secret API [keys](https://uploadcare.com/documentation/keys/) in a way you prefer (e.g., by using a `$_ENV` variable):\n\nAdd API keys to your configuration object. For example:\n\n```php\n# config.php\n$_ENV['UPLOADCARE_PUBLIC_KEY'] = '\u003cyour public key\u003e';\n$_ENV['UPLOADCARE_SECRET_KEY'] = '\u003cyour secret key\u003e';\n```\n\n**Step 4** — include a standard composer autoload file:\n\n```php\nrequire_once 'vendor/autoload.php';\n```\n\n**Step 5** — create an object of the `Uploadcare\\Configuration` class,\n\n```php\n$configuration = Uploadcare\\Configuration::create($_ENV['UPLOADCARE_PUBLIC_KEY'], $_ENV['UPLOADCARE_SECRET_KEY']);\n```\n\nAll further operations will use this configuration object.\n\n## Configuration object\n\nThere are a few ways to make a valid configuration object. We recommend using the static method of the class:\n\n```php\n$configuration = \\Uploadcare\\Configuration::create('\u003cyour public key\u003e', '\u003cyour secret key\u003e');\n```\n\nAlternatively, you can create a Security signature, HTTP client, and Serializer classes explicitly. Then create a configuration:\n\n```php\n$sign = new \\Uploadcare\\Security\\Signature('\u003cyour secret key\u003e', 3600); // Must be an instance of \\Uploadcare\\Interfaces\\SignatureInterface\n$client = \\Uploadcare\\Client\\ClientFactory::createClient(); // Must be an instance of \\GuzzleHttp\\ClientInterface\n$serializer = new \\Uploadcare\\Serializer\\Serializer(new \\Uploadcare\\Serializer\\SnackCaseConverter()); // Must be an instance of \\Uploadcare\\Interfaces\\Serializer\\SerializerInterface\n\n$configuration = new \\Uploadcare\\Configuration('\u003cyour public key\u003e', $sign, $client, $serializer);\n```\n\nAs you can see, the factory method is more convenient for standard usage.\n\n## Usage\n\nYou can find the full example in this [Uploadcare example project](https://github.com/uploadcare/uploadcare-php-example).\n\nFirst, create an API object:\n\n```php\n$configuration = \\Uploadcare\\Configuration::create($_ENV['UPLOADCARE_PUBLIC_KEY'], $_ENV['UPLOADCARE_SECRET_KEY']);\n$api = new \\Uploadcare\\Api($configuration);\n```\n\n### Uploading files\n\nThis section describes multiple ways of uploading files to Uploadcare.\n\nYou can use the core API object for any upload type:\n\n```php\n$configuration = \\Uploadcare\\Configuration::create($_ENV['UPLOADCARE_PUBLIC_KEY'], $_ENV['UPLOADCARE_SECRET_KEY']);\n$uploader = (new \\Uploadcare\\Api($configuration))-\u003euploader();\n```\n\nFirst of all, files can be uploaded **from URL**. The following code returns a token to check file upload status,\n\n```php\n$url = 'https://httpbin.org/image/jpeg';\n$result = $uploader-\u003efromUrl($url, 'image/jpeg'); // If success, $result will be string to check upload status (see below)\n```\n\nYou can upload files from URL **synchronically**,\n\n```php\n$url = 'https://httpbin.org/image/jpeg';\n$result = $uploader-\u003esyncUploadFromUrl($url, 'image/jpeg'); // $result is Uploadcare\\Interfaces\\File\\FileInfoInterface \n```\n\nCheck an uploading file status,\n\n```php\n$url = 'https://httpbin.org/image/jpeg';\n$result = $uploader-\u003efromUrl($url, 'image/jpeg'); \n$status = $uploader-\u003echeckStatus($result); // Instance of Uploadcare\\Interfaces\\File\\FileInfoInterface with isReady() === false until file is not uploaded.\n```\n\nAnother way of uploading files is by using **a path**,\n\n```php\n$path = __DIR__ . '/squirrel.jpg';\n$result = $uploader-\u003efromPath($path, 'image/jpeg');  // In success $result will contain uploaded Uploadcare\\File class\n```\n\nIt’s also relevant when using file pointers,\n\n```php\n$path = __DIR__ . '/squirrel.jpg';\n$result = $uploader-\u003efromResource(\\fopen($path, 'rb'), 'image/jpeg');\n```\n\nThere's an option of uploading a file **from its contents**. You’ll need to specify MIME-types as well:\n\n```php\n$path = __DIR__ . '/squirrel.jpg';\n$result = $uploader-\u003efromContent(\\file_get_contents($path), 'image/jpeg');\n```\n\nSecure signature. If you are using secure uploads, you can use `getSignature` method to fetch an instance of `SignatureInterface`. For example:\n\n```php\n$configuration = \\Uploadcare\\Configuration::create($_ENV['UPLOADCARE_PUBLIC_KEY'], $_ENV['UPLOADCARE_SECRET_KEY']);\n$uploader = (new \\Uploadcare\\Api($configuration))-\u003euploader();\n$signature = $uploader-\u003egetSignature();\n\n$key = $signature-\u003egetSignature(); // Sign string\n$expired = $signature-\u003egetExpire()-\u003egetTimestamp(); // Time when secure signature will expire\n```\n\n#### File metadata\n\nEvery upload method can set a [file metadata](https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/File-metadata). For example:\n\n```php\n$path = __DIR__ . '/squirrel.jpg';\n$result = $uploader-\u003efromPath($path, 'image/jpeg', null, '1', ['type' =\u003e 'animal', 'kind' =\u003e 'squirrel']);\n```\n\nYou will see this values in a `metadata` object of `Uploadcare\\File` response.\n\n### Multipart upload\n\nIf you have a large file (more than 100Mb / 10485760 bytes), the uploader will automatically process it with a [multipart upload](https://uploadcare.com/api-refs/upload-api/#operation/multipartFileUploadStart). It'll take more time to upload, and also we don’t recommend it for a web environment.\n\n#### `Uploadcare\\File` class\n\nThis class implements `Uploadcare\\Interfaces\\File\\FileInfoInterface` and it has additional methods (besides the interface):\n\n- `store()` — Stores this file in storage. Returns `Uploadcare\\File` object.\n- `delete()` — Deletes this file. Returns `Uploadcare\\File` object.\n- `copyToLocalStorage($store = true)` — Copies this file to local storage.\n- `copyToRemoteStorage($target, $makePublic = true, $pattern = null)` — Copies this file to remote storage.\n\nAll these operations are accessible via File API, and you can access them through the `Uploadcare\\File` object as well.\n\n## File operations\n\nFor any file operation type, you’ll need to create an `Uploadcare\\Api`  instance with configuration object and call the `file()` method:\n\n```php\n$config = \\Uploadcare\\Configuration::create($_ENV['UPLOADCARE_PUBLIC_KEY'], $_ENV['UPLOADCARE_SECRET_KEY']);\n$fileApi = (new \\Uploadcare\\Api($config))-\u003efile();\n```\n\nAfter that, you can access to file operation methods:\n\n- `listFiles($limit = 100, $orderBy = 'datetime_uploaded', $from = null, $addFields = [], $stored = null, $removed = false)` — a list of files. Returns an `Uploadcare\\FileCollection` instance (see below). Each element of collection is an `Uploadcare\\File`. Arguments:\n    - int             `$limit`     A preferred amount of files in a list for a single response. Defaults to 100, while the maximum is 1000.\n    - string          `$orderBy`   Specifies the way to sort files in a returned list.\n    - string|int|null `$from`      A starting point for a file filter. The value depends on your `$orderBy` parameter value.\n    - array           `$addFields` **Deprecated** This parameter is deprecated since v4.0.1 and will be removed in v4.1\n    - bool|null       `$stored`    `true` includes the only stored files, `false` includes temporary files. If not set (default): both stored and not stored files will be included.\n    - bool            `$removed`   `true` to only include removed files in the response, `false` to include existing files. The default value is false.\n- `nextPage(FileListResponseInterface $response)` — next page from previous answer, if next pages exist. You can use it in a simple `while` loop, for example:     \n    ```php\n    $config = \\Uploadcare\\Configuration::create($_ENV['UPLOADCARE_PUBLIC_KEY'], $_ENV['UPLOADCARE_SECRET_KEY']);\n    $fileApi = new \\Uploadcare\\Apis\\FileApi($config);\n    $page = $fileApi-\u003elistFiles(5); // Here is a FileListResponseInterface\n    while (($page = $fileApi-\u003enextPage($page)) !== null) {\n      $files = $page-\u003egetResults(); \n    }\n    ```\n- `getPageRequestParameters(string | null $url)` — Get an array with next page request parameters. Use it to create links to the previous/next page of the list.\n- `storeFile(string $id)` — Stores a single file by UUID. Returns the `Uploadcare\\File` (`FileInfoInterface`).\n    Takes file UUID as an argument.\n- `deleteFile(string $id)` — Removes individual files. Returns file info.\n    Takes file UUID as an argument.\n- `fileInfo(string $id)` — Once you obtain a list of files, you might want to acquire some file-specific info. Returns `FileInfoInterface`.\n    Takes array of file UUID's as an argument.\n- `batchStoreFile(array $ids)` — Used to store multiple files in one step. Supports up to 100 files per request. Takes an array of file UUID's as an argument.\n- `batchDeleteFile(array $ids)` — Used to delete multiple files in one step. Takes an array of file UUID's as an argument.\n- `copyToLocalStorage(string $source, bool $store)` — Used to copy original files, or their modified versions to a default storage. Arguments:\n    - `$source` — A CDN URL or just UUID of a file subjected to copy.\n    - `$store` Parameter only applies to the Uploadcare storage.\n- `copyToRemoteStorage(string $source, string $target, bool $makePublic = true, string $pattern = '${default}')` — copies original files, or their modified versions to a custom storage. Arguments:\n    - `$source` — CDN URL or just UUID of a file that’s being copied.\n    - `$target` — Defines a custom storage name related to your project and implies you are copying a file to a specified custom storage. Keep in mind that you can have multiple storages associated with one S3 bucket.\n    - `$makePublic` — `true` to make copied files available via public links, `false` to reverse the behavior.\n    - `$pattern` — The parameter is used to specify file names Uploadcare passes to a custom storage. In case when the parameter is omitted, we use a pattern of your custom storage. Use any combination of allowed values.\n    \nSee the [API documentation](https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/File) for more details.\n\n### `Uploadcare\\FileCollection` class\n\nThis class implements `Uploadcare\\Interfaces\\File\\CollectionInterface` and has additional methods besides the interface:\n\n- `store()` — Stores all files in a collection. Calls `FileApi::batchStoreFile()` under the hood.\n- `delete()` — Deletes all files in a collection.\n\nEach file in the collection is an object of the `Uploadcare\\File` class.\n\n### `Uploadcare\\File` class\n\nThis class implements `FileInfoInterface` and has additional methods for file operations:\n- `store()` — Stores the current file.\n- `delete()` — Deletes the current file.\n- `copyToLocalStorage($store = true)` — Copies the current file to the default storage.\n- `copyToRemoteStorage($target, $makePublic = true, $pattern = null)` — Copies the current file to a custom storage;\n\nAs you can see, additional methods help you to call API methods without direct API calls.\n\n## Addons operations\n\nUploadcare provide a few additional operations with images.\n\n### [Object Recognition](https://uploadcare.com/docs/intelligence/object-recognition/)\n\nTo call object recognition from library:\n\n```php\n$configuration = \\Uploadcare\\Configuration::create($_ENV['UPLOADCARE_PUBLIC_KEY'], $_ENV['UPLOADCARE_SECRET_KEY']);\n\n$api = new \\Uploadcare\\Api($configuration);\n/** @var \\Uploadcare\\Interfaces\\File\\FileInfoInterface $file */\n$file = $api-\u003efile()-\u003elistFiles()-\u003egetResults()-\u003efirst();\n\n# Request recognition, get token to check status\n$token = $api-\u003eaddons()-\u003erequestAwsRecognition($file);\nwhile (($status = $api-\u003eaddons()-\u003echeckAwsRecognition($token)) !== 'done') {\n    \\usleep(1000);\n    if ($status === 'error') {\n        throw new \\Exception('Error in process');\n    }\n}\n\n$recognitionData = $api-\u003efile()-\u003efileInfo($file-\u003egetUuid())-\u003egetAppdata()-\u003egetAwsRekognitionDetectLabels(); // Instance of \\Uploadcare\\Interfaces\\File\\AppData\\AwsRecognitionLabelsInterface\n```\n\n### [Unsafe content detection](https://uploadcare.com/docs/unsafe-content/)\n\nTo call unsafe content detection from the library:\n\n```php\n$configuration = \\Uploadcare\\Configuration::create($_ENV['UPLOADCARE_PUBLIC_KEY'], $_ENV['UPLOADCARE_SECRET_KEY']);\n\n$api = new \\Uploadcare\\Api($configuration);\n/** @var \\Uploadcare\\Interfaces\\File\\FileInfoInterface $file */\n$file = $api-\u003efile()-\u003elistFiles()-\u003egetResults()-\u003efirst();\n\n# Request recognition, get token to check status\n$token = $api-\u003eaddons()-\u003erequestAwsRecognitionModeration($file);\nwhile (($status = $api-\u003eaddons()-\u003echeckAwsRecognitionModeration($token)) !== 'done') {\n    \\usleep(1000);\n    if ($status === 'error') {\n        throw new \\Exception('Error in process');\n    }\n}\n\n$recognitionModerationData = $api-\u003efile()-\u003efileInfo($file-\u003egetUuid())-\u003egetAppdata()-\u003egetAwsRekognitionDetectModerationLabels() // Instance of \\Uploadcare\\Interfaces\\File\\AppData\\AwsModerationLabelInterface\n```\n\n### [Remove background](https://uploadcare.com/docs/remove-bg/)\n\nRemove background from image:\n\n```php\n$configuration = \\Uploadcare\\Configuration::create($_ENV['UPLOADCARE_PUBLIC_KEY'], $_ENV['UPLOADCARE_SECRET_KEY']);\n\n$api = new \\Uploadcare\\Api($configuration);\n/** @var \\Uploadcare\\Interfaces\\File\\FileInfoInterface $file */\n$file = $api-\u003efile()-\u003elistFiles()-\u003egetResults()-\u003efirst();\n\n# Request recognition, get token to check status\n$token = $api-\u003eaddons()-\u003erequestRemoveBackground($file);\nwhile (($status = $api-\u003eaddons()-\u003echeckRemoveBackground($token)) !== 'done') {\n    \\usleep(1000);\n    if ($status === 'error') {\n        throw new \\Exception('Error in process');\n    }\n}\n\n$removeBackgroundData = $api-\u003efile()-\u003efileInfo($file-\u003egetUuid())-\u003egetAppdata()-\u003egetRemoveBg(); // Instance of \\Uploadcare\\Interfaces\\File\\AppData\\RemoveBgInterface\n```\n\n### [Antivirus scan](https://www.clamav.net/)\n\n```php\n$configuration = \\Uploadcare\\Configuration::create($_ENV['UPLOADCARE_PUBLIC_KEY'], $_ENV['UPLOADCARE_SECRET_KEY']);\n$api = new \\Uploadcare\\Api($configuration);\n/** @var \\Uploadcare\\Interfaces\\File\\FileInfoInterface $file */\n$file = $api-\u003efile()-\u003elistFiles()-\u003egetResults()-\u003efirst();\n\n# Request antivirus scan and get token:\n$token = $api-\u003eaddons()-\u003erequestAntivirusScan($file);\nwhile (($status = $api-\u003eaddons()-\u003echeckAntivirusScan($token)) !== 'done') {\n    \\usleep(1000);\n    if ($status === 'error') {\n        throw new \\Exception('Error in process');\n    }\n}\n```\n\n## Group operations\n\nFor any type of group operation you need to create an `Uploadcare\\Api` instance with a configuration object and call the `group()` method:\n\n```php\n$config = \\Uploadcare\\Configuration::create($_ENV['UPLOADCARE_PUBLIC_KEY'], $_ENV['UPLOADCARE_SECRET_KEY']);\n$groupApi = (new \\Uploadcare\\Api($config))-\u003egroup();\n```\n\nAfter that, you can access group operation methods:\n\n- `createGroup($files)` — Creates a file group. You can pass the array of IDs or `Uploadcare\\File\\FileCollection` as an argument. Returns an `Uploadcare\\File\\Group` object.\n- `listGroups($limit, $asc = true)` — Gets a paginated list of groups. The default limit is 100, and the default sorting is by the date and time created (ascending). You can reverse the sorting order to descending dates with `$asc = false`. Returns `Uploadcare\\Response\\GroupListResponse`.\n- `groupInfo($id)` — Gets a file group info by UUID. Returns an `Uploadcare\\Group` object.\n- `removeGroup($id): void` — delete group by UUID or `Uploadcare\\Group` object.\n\n### `Uploadcare\\Group` class\n\nThis class implements `Uploadcare\\Interfaces\\GroupInterface`.    \nThe `getFiles()` method of the `Uploadcare\\Group` object returns [FileCollection](#uploadcarefilecollection-class).\n\n## Project operations\n\nAs usual, Project API is accessible by the main API object:\n\n```php\n$config = \\Uploadcare\\Configuration::create($_ENV['UPLOADCARE_PUBLIC_KEY'], $_ENV['UPLOADCARE_SECRET_KEY']);\n$projectApi = (new \\Uploadcare\\Api($config))-\u003eproject();\n```\n\nYou can get the project information by calling the `getProjectInfo` method:\n\n```php\n$projectInfo = $projectApi-\u003egetProjectInfo();\n```\n\nNow, the `$projectInfo` variable contains the `Uploadcare\\Interfaces\\Response\\ProjectInfoInterface` implementation with the following methods:\n\n- `getCollaborators()` — Array with collaborators information. Keys are collaborator emails and values are collaborator names.\n- `getName()` — Project name as a string.\n- `getPubKey()` — Project public key as string.\n- `isAutostoreEnabled()` — Returns `true` if the project files are stored automatically.\n\n## [Webhooks](https://uploadcare.com/docs/webhooks/)\n\nCall the webhook API:\n\n```php\n$config = \\Uploadcare\\Configuration::create($_ENV['UPLOADCARE_PUBLIC_KEY'], $_ENV['UPLOADCARE_SECRET_KEY']);\n$webhookApi = (new \\Uploadcare\\Api($config))-\u003ewebhook();\n```\n\nThe methods are:\n\n- `listWebhooks()` — Returns a list of project webhooks as an instance of an `Uploadcare\\WebhookCollection` class. Each element of this collection is an instance of a `Uploadcare\\Webhook` class (see below);\n- `createWebhook(string $targetUrl, bool $isActive = true, string $signingSecret = null, string $event = 'file.uploaded')` — Creates a new webhook for the event. Returns the `Uploadcare\\Webhook` class. Event types described [here](https://uploadcare.com/docs/webhooks/#event-types)\n- `updateWebhook($id, array $parameters)` — Updates an existing webhook with these parameters. Parameters can be:\n    - `target_url` — A target callback URL;\n    - `event` — The only `file.uploaded` event is supported at the moment.\n    - `is_active` — Returns the webhook activity status.\n    - `signing_secret` — Webhook signing secret. See [Secure Webhooks](https://uploadcare.com/docs/security/secure-webhooks/)\n- `deleteWebhook` — Deletes a webhook by URL.\n\n#### `Uploadcare\\Webhook` class\n\nThis class implements `Uploadcare\\Interfaces\\Response\\WebhookInterface` and has additional methods besides the interface:\n\n- `delete()` — Deletes a webhook. Calls `Uploadcare\\Interfaces\\Api\\WebhookApiInterface::deleteWebhook()` under the hood;\n- `updateUrl($url)` — Updates a webhook with a new URL (`WebhookApiInterface::updateWebhook()`).\n- `activate()` — Sets a webhook active (`WebhookApiInterface::updateWebhook()`).\n- `deactivate()` — Sets a webhook as not active (`WebhookApiInterface::updateWebhook()`).\n\n## Conversion operations\n\nYou can convert documents, images and encode video files with Conversion API.\n\n### Document and image conversion\n\nCreate a new object for a subsequent conversion request:\n\n```php\n$request = new \\Uploadcare\\Conversion\\DocumentConversionRequest('pdf');\n```\n\nThe default arguments and examples are:\n\n- `$targetFormat = 'pdf'` — Target format.\n- `$throwError = false` — If set to `true`, a wrong request will throw an exception, otherwise, it'll return null.\n- `$store = true` —  The conversion results will go to your default storage.\n- `$pageNumber = 1` — Specifies pages to convert in multi-page documents.\n\nAfter that, you can convert your file:\n\n```php\n$config = \\Uploadcare\\Configuration::create($_ENV['UPLOADCARE_PUBLIC_KEY'], $_ENV['UPLOADCARE_SECRET_KEY']);\n$convertor = (new \\Uploadcare\\Api($config))-\u003econversion();\n$result = $convertor-\u003econvertDocument($file, $request);\n```\n\nResult will contain one of two objects:\n- `ConvertedItemInterface` object with conversion result in case of successful operation, or\n- `ResponseProblemInterface` object in case of error (and `$throwError` in request sets to `false`).\n\nThe `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):\n\nYou can also pass the `true` to the `setSaveInGroup` method to the Request object.\n\n```php\n$request = (new \\Uploadcare\\Conversion\\DocumentConversionRequest('pdf'))-\u003esetSaveInGroup(true);\n```\n\nIn this case, the result of the document conversion will be stored in a group. See further details [here](https://uploadcare.com/docs/transformations/document-conversion/#multipage-conversion).\n\n```php\n$status = $convertor-\u003edocumentJobStatus($result); // or $result-\u003egetToken()\n```\n\nThis status object will implement `ConversionStatusInterface` with these methods:\n- `getStatus()` — Status string. Pending, processing, finished, failed or canceled.\n- `getError()` — An error string in case of error or null.\n- `getResult()` — The `StatusResultInterface` object.\n\nYou can request batch conversion to process multiple documents:\n\n```php\n$result = $convertor-\u003ebatchConvertDocuments($files, $request);\n```\n\n`$files` can be an array / collection of file IDs or FileInfo objects and the result will be the implementation of `BatchResponseInterface`.\n\n### Video processing\n\nGet the conversion API as in the previous step and perform `VideoEncodingRequest`\n\n```php\n$request = new \\Uploadcare\\Conversion\\VideoEncodingRequest();\n```\n\nYou can set various parameters for this request through the object setters:\n\n```php\n$request = (new \\Uploadcare\\Conversion\\VideoEncodingRequest())\n    -\u003esetHorizontalSize(1024)           // Sets the horizontal size for result.\n    -\u003esetVerticalSize(768)              // Sets the vertical size of result.\n    -\u003esetResizeMode('preserve_ratio')   // Sets the resize mode. Mode can be one of 'preserve_ratio', 'change_ratio', 'scale_crop', 'add_padding'\n    -\u003esetQuality('normal')              // Sets result quality. Can be one of 'normal', 'better', 'best', 'lighter', 'lightest'\n    -\u003esetTargetFormat('mp4')            // Sets the target format. Can be one of 'webm', 'ogg', 'mp4'. Default 'mp4'\n    -\u003esetStartTime('0:0')               // Sets the start time. Time string must be an `HHH:MM:SS.sss` or `MM:SS.sss`\n    -\u003esetEndTime('22:44')               // Sets the end time. String format like start time string\n    -\u003esetThumbs(2)                      // Sets count of video thumbs. Default 1, max 50\n    -\u003esetStore(true)                    // Tells store result at conversion ends. Default is true\n```\n\nIf you don’t set any option to conversion request, the defaults will be as follows: mp4 format, full length and normal quality.\n\nAs 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.\n\nAlso, 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.\n\n## Secure delivery\n\nYou can use your own custom domain and CDN provider for deliver files with authenticated URLs (see [original documentation](https://uploadcare.com/docs/security/secure_delivery/)).\n\nTo generate authenticated URL from the library, you should do this:\n\n- make a configuration as usual;\n- make `Uploadcare\\AuthUrl\\AuthUrlConfig` object. This object will provide token, expire timestamp and your custom domain URL generator. `$token` in the constructor must be an instance of `Uploadcare\\AuthUrl\\Token\\TokenInterface`;\n- generate secure url from `FileApi::generateSecureUrl($id)` or from `Uploadcare\\File::generateSecureUrl()`\n\nFor example:\n\n```php\nuse Uploadcare\\Configuration;\nuse Uploadcare\\AuthUrl\\AuthUrlConfig;\nuse Uploadcare\\Api;\nuse Uploadcare\\AuthUrl\\Token\\AkamaiToken;\n\n$authUrlConfig = new AuthUrlConfig('mydomain.com', new AkamaiToken('secretKey', 300));\n$config = Configuration::create($_ENV['UPLOADCARE_PUBLIC_KEY'], $_ENV['UPLOADCARE_SECRET_KEY'])\n    -\u003esetAuthUrlConfig($authUrlConfig);\n\n$api = new Api($config);\n$file = $api-\u003efile()-\u003elistFiles()-\u003egetResults()-\u003efirst();\n\n// Get secure url from file\n$secureUrl = $file-\u003egenerateSecureUrl(); // you can use KeyCdnUrlGenerator or AkamaiUrlGenerator\n\n// Or from API instance\n$secureUrlFromApi = $api-\u003efile()-\u003egenerateSecureUrl($file);\n```\n\n### Secure delivery for transformed images\n\nYou can set a custom ACL on a Secure URL with\n[Image Transformations](https://uploadcare.com/docs/transformations/image/)\napplied. Just add an Image UUID with transformations to the `generateSecureUrl`\nmethod:\n\n```php\n$api-\u003efile()-\u003egenerateSecureUrl('/*/'); # Access to all files in project\n$api-\u003efile()-\u003egenerateSecureUrl('/{uuid}/-/resize/640x/other/transformations/'); # Access to modified file version\n```\n\n--------------------------------------------------------------------\n\n## Tests\n\nPHP 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.\n\nRun tests with this command:\n\n```bash\n`vendor/bin/phpunit --exclude-group local-only`\n```\n\n`--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:\n\n```dotenv\n# tests/.env.local\nUPLOADCARE_PUBLIC_KEY=\u003cyour public key\u003e\nUPLOADCARE_secret_KEY=\u003cyour secret key\u003e\n```\n\n## Useful links\n\n[Uploadcare documentation](https://uploadcare.com/docs/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=uploadcare-php)  \n[Upload API reference](https://uploadcare.com/api-refs/upload-api/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=uploadcare-php)  \n[REST API reference](https://uploadcare.com/api-refs/rest-api/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=uploadcare-php)  \n[Changelog](https://github.com/uploadcare/uploadcare-php/blob/master/CHANGELOG.md)  \n[Contributing guide](https://github.com/uploadcare/.github/blob/master/CONTRIBUTING.md)  \n[Security policy](https://github.com/uploadcare/uploadcare-php/security/policy)  \n[Support](https://github.com/uploadcare/.github/blob/master/SUPPORT.md)  \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuploadcare%2Fuploadcare-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuploadcare%2Fuploadcare-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuploadcare%2Fuploadcare-php/lists"}