{"id":47669297,"url":"https://github.com/imagekit-developer/imagekit-php","last_synced_at":"2026-04-02T12:24:42.586Z","repository":{"id":37940161,"uuid":"233840401","full_name":"imagekit-developer/imagekit-php","owner":"imagekit-developer","description":"PHP SDK for ImageKit.io API.","archived":false,"fork":false,"pushed_at":"2025-09-21T03:12:23.000Z","size":1564,"stargazers_count":48,"open_issues_count":3,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-11-06T00:10:11.244Z","etag":null,"topics":["hacktoberfest","image-manipulation","image-optimization"],"latest_commit_sha":null,"homepage":"https://imagekit.io","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imagekit-developer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-01-14T12:50:10.000Z","updated_at":"2025-10-25T18:51:45.000Z","dependencies_parsed_at":"2024-02-08T05:24:10.010Z","dependency_job_id":"0bb9477a-c24f-4353-adad-a1e2adff7441","html_url":"https://github.com/imagekit-developer/imagekit-php","commit_stats":{"total_commits":239,"total_committers":12,"mean_commits":"19.916666666666668","dds":0.5271966527196652,"last_synced_commit":"01b87a33c10ac7f0eec3907c4fedd2e7b47a3072"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/imagekit-developer/imagekit-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagekit-developer%2Fimagekit-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagekit-developer%2Fimagekit-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagekit-developer%2Fimagekit-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagekit-developer%2Fimagekit-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imagekit-developer","download_url":"https://codeload.github.com/imagekit-developer/imagekit-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imagekit-developer%2Fimagekit-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31306024,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T09:48:21.550Z","status":"ssl_error","status_checked_at":"2026-04-02T09:48:19.196Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["hacktoberfest","image-manipulation","image-optimization"],"created_at":"2026-04-02T12:24:41.932Z","updated_at":"2026-04-02T12:24:42.568Z","avatar_url":"https://github.com/imagekit-developer.png","language":"PHP","readme":"# PHP SDK for ImageKit\n\n[![Packagist](https://img.shields.io/packagist/v/imagekit/imagekit.svg)](https://packagist.org/packages/imagekit/imagekit)  [![Packagist](https://img.shields.io/packagist/dt/imagekit/imagekit.svg)](https://packagist.org/packages/imagekit/imagekit)  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![codecov](https://codecov.io/gh/imagekit-developer/imagekit-php/branch/master/graph/badge.svg)](https://codecov.io/gh/imagekit-developer/imagekit-php) [![Twitter Follow](https://img.shields.io/twitter/follow/imagekitio?label=Follow\u0026style=social)](https://twitter.com/ImagekitIo)\n[![PHP Test CI](https://github.com/imagekit-developer/imagekit-php/actions/workflows/test.yml/badge.svg)](https://github.com/imagekit-developer/imagekit-php/actions/workflows/test.yml) [![PHP Coverage CI](https://github.com/imagekit-developer/imagekit-php/actions/workflows/coverage.yml/badge.svg)](https://github.com/imagekit-developer/imagekit-php/actions/workflows/coverage.yml) [![Wiki Documentation](https://img.shields.io/badge/wiki-documentation-forestgreen)](https://github.com/imagekit-developer/imagekit-php/wiki)\n\nPHP SDK for [ImageKit](https://imagekit.io/) implements the new APIs and interface for different file operations.\n\nImageKit is complete media storage, optimization, and transformation solution that comes with an [image and video CDN](https://imagekit.io/). It can be integrated with your existing infrastructure - storage like AWS S3, web servers, your CDN, and custom domain names, allowing you to deliver optimized images in minutes with minimal code changes.\n\n- [Key Features](#key-features)\n- [Requirements](#requirements)\n- [Version Support](#version-support)\n- [Breaking changes](#breaking-changes)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Getting Started](#getting-started)\n- [Quick Examples](#quick-examples)\n    * [Create an ImageKit Instance](#create-an-imagekit-instance)\n    * [URL Generation](#url-generation)\n    * [File Upload](#file-upload)\n- [Demo Application](#demo-application)\n- [URL Generation](#url-generation-1)\n- [Signed URL \u0026 Image Transformations](#applying-chained-transformations-common-image-manipulations--signed-url)\n- [Server-side File Upload](#server-side-file-upload)\n- [File Management](#file-management)\n- [Custom Metadata Fields API](#custom-metadata-fields-api)\n- [Utility Function](#utility-functions)\n- [Opening Issues](#opening-issues)\n- [Support](#support)\n- [Resources](#resources)\n- [License](#license)\n\n## Key Features\n- [URL Generation](#url-generation)\n- [Transformations](#1-chained-transformations-as-a-query-parameter)\n- [Secure URLS](#6-signed-url)\n- [File Upload](#server-side-file-upload)\n- [File Management](#file-management)\n\n## Requirements\n* PHP 5.6+\n* [JSON PHP Extension](https://www.php.net/manual/en/book.json.php)\n* [cURL PHP Extension](https://www.php.net/manual/en/book.curl.php)\n\n## Version Support\n| SDK Version | PHP 5.4 | PHP 5.5 | PHP 5.6 | PHP 7.x | PHP 8.x |\n|-------------|---------|---------|---------|---------|---------|\n| 4.x         | ❌     | ❌      | ✔️       | ✔️     |✔️      |\n| 3.x         | ❌     | ❌      | ✔️       | ✔️     |✔️      |\n| 2.x         | ❌     | ❌      | ✔️       | ✔️     |✔️      |\n| 1.x         | ❌     | ✔️      | ✔️       | ✔️     |✔️      |\n\n## Breaking changes\n\n### Upgrading from 3.x to 4.x version\n\n1. Overlay syntax update\n\n* In version 4.0.0, we've removed the old overlay syntax parameters for transformations, such as `oi`, `ot`, `obg`, and [more](https://docs.imagekit.io/features/image-transformations/overlay). These parameters are deprecated and will start returning errors when used in URLs. Please migrate to the new layers syntax that supports overlay nesting, provides better positional control, and allows more transformations at the layer level. You can start with [examples](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#examples) to learn quickly.\n* You can migrate to the new layers syntax using the `raw` transformation parameter.\n\n## Installation\n\nYou can install the bindings via [Composer](http://getcomposer.org/). Run the following command:\n\n```bash\ncomposer require imagekit/imagekit\n```\nTo use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):\n```php\nrequire_once('vendor/autoload.php');\n```\n\n## Usage\n\nYou can use this PHP SDK for three different methods - URL generation, file upload, and file management. The usage of the SDK has been explained below.\n\n* `URL Generation`\n* `File Upload`\n* `File Management`\n\n## Getting Started\n1. **Sign up for ImageKit** – Before you begin, you need to sign up for an [ImageKit account](https://imagekit.io/registration/)\n2. Get your [API Keys](https://docs.imagekit.io/api-reference/api-introduction/api-keys) from [developer options](https://imagekit.io/dashboard/developer) inside the dashboard.\n3. **Minimum requirements** – To use PHP SDK, your system must meet the minimum requirements, including having **PHP \u003e= 5.6**. We highly recommend having it compiled with the cURL extension and cURL 7.16.2+ compiled with a TLS backend (e.g., NSS or OpenSSL).\n4. **Install the SDK** – Using Composer is the recommended way to install the ImageKit SDK for PHP. The SDK is available via [Packagist](http://packagist.org/) under the [`imagekit/imagekit`](https://packagist.org/packages/imagekit/imagekit) package. If Composer is installed globally on your system, you can run the following in the base directory of your project to add the SDK as a dependency:\n   ```\n   composer require imagekit/imagekit\n   ```\n   Please see the [Installation](#installation) section for more detailed information about installing.\n5. **Using the SDK** – The best way to become familiar with how to use the SDK is to follow the examples provided in the [quick start guide](https://docs.imagekit.io/getting-started/quickstart-guides/php).\n\n## Quick Examples\n\n#### Create an ImageKit Instance\n```php  \n// Require the Composer autoloader.\nrequire 'vendor/autoload.php';\nuse ImageKit\\ImageKit;  \n  \n$imageKit = new ImageKit(\n    \"your_public_key\",\n    \"your_private_key\",\n    \"your_url_endpoint\"\n);\n```\n\n#### URL Generation\n```php\n// For URL Generation, works for both images and videos\n$imageURL = $imageKit-\u003eurl(\n    [\n        'path' =\u003e '/default-image.jpg',\n    ]\n);\necho $imageURL;\n```\n\n#### File Upload\n```php\n// For File Upload\n$uploadFile = $imageKit-\u003euploadFile([\n    'file' =\u003e 'file-url', # required, \"binary\",\"base64\" or \"file url\"\n    'fileName' =\u003e 'new-file' # required\n    'checks' =\u003e '\"file.size\" \u003c \"1mb\"' //  optional `checks` parameters can be used to run server-side checks before files are uploaded to the Media Library.\n]);\n```  \n\n#### Response Structure\nFollowing is the response for [server-side file upload API](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload#response-code-and-structure-json)\n\n```json\n{\n    \"error\": null,\n    \"result\": {\n        \"fileId\": \"6286329dfef1b033aee60211\",\n        \"name\": \"your_file_name_S-PgGysnR.jpg\",\n        \"size\": 94466,\n        \"versionInfo\": {\n            \"id\": \"6286329dfef1b033aee60211\",\n            \"name\": \"Version 1\"\n        },\n        \"filePath\": \"/your_file_name_S-PgGysnR.jpg\",\n        \"url\": \"https://ik.imagekit.io/demo/your_file_name_S-PgGysnR.jpg\",\n        \"fileType\": \"image\",\n        \"height\": 640,\n        \"width\": 960,\n        \"thumbnailUrl\": \"https://ik.imagekit.io/demo/tr:n-ik_ml_thumbnail/your_file_name_S-PgGysnR.jpg\",\n        \"tags\": [],\n        \"AITags\": null,\n        \"customMetadata\": { },\n        \"extensionStatus\": {}\n    },\n    \"responseMetadata\":{\n        \"headers\":{\n            \"access-control-allow-origin\": \"*\",\n            \"x-ik-requestid\": \"e98f2464-2a86-4934-a5ab-9a226df012c9\",\n            \"content-type\": \"application/json; charset=utf-8\",\n            \"content-length\": \"434\",\n            \"etag\": 'W/\"1b2-reNzjRCFNt45rEyD7yFY/dk+Ghg\"',\n            \"date\": \"Thu, 16 Jun 2022 14:22:01 GMT\",\n            \"x-request-id\": \"e98f2464-2a86-4934-a5ab-9a226df012c9\"\n        },\n        \"raw\":{\n            \"fileId\": \"6286329dfef1b033aee60211\",\n            \"name\": \"your_file_name_S-PgGysnR.jpg\",\n            \"size\": 94466,\n            \"versionInfo\": {\n                \"id\": \"6286329dfef1b033aee60211\",\n                \"name\": \"Version 1\"\n            },\n            \"filePath\": \"/your_file_name_S-PgGysnR.jpg\",\n            \"url\": \"https://ik.imagekit.io/demo/your_file_name_S-PgGysnR.jpg\",\n            \"fileType\": \"image\",\n            \"height\": 640,\n            \"width\": 960,\n            \"thumbnailUrl\": \"https://ik.imagekit.io/demo/tr:n-ik_ml_thumbnail/your_file_name_S-PgGysnR.jpg\",\n            \"tags\": [],\n            \"AITags\": null,\n            \"customMetadata\": { },\n            \"extensionStatus\": {}\n        },\n        \"statusCode\":200\n    }\n}\n```\n\n## Demo application\n\n* Step-by-step PHP quick start guide - https://docs.imagekit.io/getting-started/quickstart-guides/php\n* You can also run the demo application in this repository's [sample](/sample) folder.\n  ```sh  \n  cd sample\n  php sample.php\n  ```  \n  \n## URL generation \n\n### Using relative file path and URL endpoint\n  \nThis method allows you to create an URL to access a file using the relative file path and the ImageKit URL endpoint (`urlEndpoint`). The file can be an image, video, or any other static file supported by ImageKit.\n  \n#### Example\n\n```php  \n$imageURL = $imageKit-\u003eurl(\n    [\n        'path' =\u003e '/default-image.jpg', \n        'transformation' =\u003e [\n            [\n                'height' =\u003e '300', \n                'width' =\u003e '400'\n            ]\n        ]\n    ]\n);\n```  \n\n#### Response\n\n```  \nhttps://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400/default-image.jpg \n```  \n\n### Using full image URL\nThis method allows you to add transformation parameters to an absolute URL. For example, if you have configured a custom CNAME and have absolute asset URLs in your database or CMS, you will often need this.\n\n#### Example\n```php  \n$imageURL = $imageKit-\u003eurl([\n    'src' =\u003e 'https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg',\n    'transformation' =\u003e [\n        [\n            'height' =\u003e '300',\n            'width' =\u003e '400'\n        ]\n    ]\n]);\n```  \n\n#### Response\n```\nhttps://ik.imagekit.io/your_imagekit_id/endpoint/tr:h-300,w-400/default-image.jpg  \n```  \n\nThe `$imageKit-\u003eurl()` method accepts the following parameters.\n\n| Option                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |  \n| :-------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |  \n| urlEndpoint           | Optional. The base URL to be appended before the path of the image. If not specified, the URL Endpoint specified at the time of SDK initialization is used. For example, https://ik.imagekit.io/your_imagekit_id/endpoint/                                                                                                                                                                                                                                                                                                                                                               |  \n| path                  | Conditional. This is the path at which the image exists. For example, `/path/to/image.jpg`. Either the `path` or `src` parameter needs to be specified for URL generation.                                                                                                                                                                                                                                                                                                                                                                                                                |  \n| src                   | Conditional. This is the complete URL of an image already mapped to ImageKit. For example, `https://ik.imagekit.io/your_imagekit_id/endpoint/path/to/image.jpg`. Either the `path` or `src` parameter needs to be specified for URL generation.                                                                                                                                                                                                                                                                                                                                           |  \n| transformation        | Optional. An array of objects specifying the transformation to be applied in the URL. The transformation name and the value should be specified as a key-value pair in the object. Different steps of a [chained transformation](https://docs.imagekit.io/features/image-transformations/chained-transformations) can be specified as different objects of the array. The complete [List of supported transformations](#list-of-supported-transformations) in the SDK and some examples of using them are given later. If you use a transformation name that is not specified in the SDK, it gets applied as it is in the URL. |  \n| transformationPosition | Optional. The default value is `path` which places the transformation string as a path parameter in the URL. It can also be specified as `query`, which adds the transformation string as the query parameter `tr` in the URL. The transformation string is always added as a query parameter if you use the `src` parameter to create the URL.                                                                                                                                                                                                                                                 |  \n| queryParameters       | Optional. These are the other query parameters that you want to add to the final URL. These can be any query parameters and are not necessarily related to ImageKit. Especially useful if you want to add some versioning parameters to your URLs.                                                                                                                                                                                                                                                                                                                                           |  \n| signed                | Optional. Boolean. The default value is `false`. If set to `true`, the SDK generates a signed image URL adding the image signature to the image URL.                                                                                                                                                                                                                                                                                                              |  \n| expireSeconds         | Optional. Integer. It is used along with the `signed` parameter. It specifies the time in seconds from now when the signed URL will expire. If specified, the URL contains the expiry timestamp in the URL, and the image signature is modified accordingly.                                                                                                                                                \n\n### Applying chained transformations, common image manipulations \u0026 signed URL\n\nThis section covers the basics:\n\n* [Chained Transformations as a query parameter](#1-chained-transformations-as-a-query-parameter)\n* [Image enhancement \u0026 color manipulation](#2-image-enhancement-and-color-manipulation)\n* [Resizing images and videos](#3-resizing-images-and-videos)\n* [Quality manipulation](#4-quality-manipulation)\n* [Adding overlays](#5-adding-overlays)\n* [Signed URL](#6-signed-url)\n\nThe PHP SDK gives a name to each transformation parameter e.g. `height` for `h` and `width` for `w` parameter. It makes your code more readable. See the [Full list of supported transformations](#list-of-supported-transformations).\n\n👉 If the property does not match any of the available options, it is added as it is. For example:\n```php\n[\n    'effectGray' =\u003e 'e-grayscale'\n]\n// and\n[\n    'e-grayscale' =\u003e ''\n]\n// works the same\n```\n👉 Note that you can also use the `h` and `w` parameters instead of `height` and `width`. \n\nFor more examples, check the [Demo Application](https://github.com/imagekit-developer/imagekit-php/tree/master/sample).\n\n\n### 1. Chained transformations as a query parameter\n\n#### Example\n```php  \n$imageURL = $imageKit-\u003eurl([\n    'path' =\u003e '/default-image.jpg',\n    'urlEndpoint' =\u003e 'https://ik.imagekit.io/your_imagekit_id/endpoint/', \n    'transformation' =\u003e [\n        [\n            'height' =\u003e '300',\n            'width' =\u003e '400'\n        ],\n        [\n            'rotation' =\u003e 90\n        ],\n    ], \n    'transformationPosition' =\u003e 'query'\n]);\n```  \n#### Response\n```  \nhttps://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=h-300,w-400:rt-90\n```  \n\n### 2. Image enhancement and color manipulation\n\nSome transformations like [contrast stretch](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#contrast-stretch-e-contrast) , [sharpen](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#sharpen-e-sharpen) and [unsharp mask](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#unsharp-mask-e-usm) can be added to the URL with or without any other value. To use such transforms without specifying a value, specify the value as \"-\" in the transformation object. Otherwise, specify the value that you want to be added to this transformation.\n\n#### Example\n```php  \n$imageURL = $imageKit-\u003eurl([\n    'src' =\u003e 'https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg', \n    'transformation' =\u003e \n    [\n        [\n            'format' =\u003e 'jpg', \n            'progressive' =\u003e true,\n            'effectSharpen' =\u003e '-', \n            'effectContrast' =\u003e '1'\n        ]\n    ]\n]);\n```  \n#### Response\n```  \nhttps://ik.imagekit.io/your_imagekit_id/endpoint/tr:f-jpg,pr-true,e-sharpen,e-contrast-1/default-image.jpg \n```  \n\n### 3. Resizing images and videos\nLet's resize the image to `width` 400 and `height` 300.\nCheck detailed instructions on [resize, crop, and other Common transformations](https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations)\n\n#### Example\n```php\n$imageURL = $imageKit-\u003eurl(array(\n    'path' =\u003e '/default-image.jpg',\n    'transformation' =\u003e [\n        [\n            'height' =\u003e '300',\n            'width' =\u003e '400',\n        ]\n    ]\n));\n```\n#### Response\n```\nhttps://ik.imagekit.io/your_imagekit_id/tr:w-400,h-300/default-image.jpg\n```\n\n### 4. Quality manipulation\nYou can use the [quality parameter](https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#quality-q) to change quality like this.\n\n#### Example\n```php\n$imageURL = $imageKit-\u003eurl(array(\n    'path' =\u003e '/default-image.jpg',\n    'transformation' =\u003e [\n        [\n            'quality' =\u003e '40',\n        ]\n    ]\n));\n```\n\n#### Response\n```\nhttps://ik.imagekit.io/your_imagekit_id/tr:q-40/default-image.jpg\n```\n\n### 5. Adding overlays\n\nImageKit.io enables you to apply overlays to [images](https://docs.imagekit.io/features/image-transformations/overlay-using-layers) and [videos](https://docs.imagekit.io/features/video-transformation/overlay) using the raw parameter with the concept of [layers](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#layers). The raw parameter facilitates incorporating transformations directly in the URL. A layer is a distinct type of transformation that allows you to define an asset to serve as an overlay, along with its positioning and additional transformations.\n\n#### Text as overlays\n\nYou can add any text string over a base video or image using a text layer (l-text).\n\nFor example:\n\n```php\n$imageURL = $imageKit-\u003eurl(array(\n    'path' =\u003e '/default-image.jpg',\n    'urlEndpoint' =\u003e 'https://ik.imagekit.io/your_imagekit_id'\n    \n    'transformation' =\u003e [\n        [\n            'height' =\u003e '300',\n            'width' =\u003e '400',\n            'raw': \"l-text,i-Imagekit,fs-50,l-end\"\n        ]\n    ]\n));\n```\n#### Sample Result URL\n```\nhttps://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-text,i-Imagekit,fs-50,l-end/default-image.jpg\n```\n\n#### Image as overlays\n\nYou can add an image over a base video or image using an image layer (l-image).\n\nFor example:\n\n```php\n$imageURL = $imageKit-\u003eurl(array(\n    'path' =\u003e '/default-image.jpg',\n    'urlEndpoint' =\u003e 'https://ik.imagekit.io/your_imagekit_id'\n    \n    'transformation' =\u003e [\n        [\n            'height' =\u003e '300',\n            'width' =\u003e '400',\n            'raw': \"l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end\"\n        ]\n    ]\n));\n```\n#### Sample Result URL\n```\nhttps://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end/default-image.jpg\n```\n\n#### Solid color blocks as overlays\n\nYou can add solid color blocks over a base video or image using an image layer (l-image).\n\nFor example:\n\n```php\n$imageURL = $imageKit-\u003eurl(array(\n    'path' =\u003e '/img/sample-video.mp4',\n    'urlEndpoint' =\u003e 'https://ik.imagekit.io/your_imagekit_id'\n    \n    'transformation' =\u003e [\n        [\n            'height' =\u003e '300',\n            'width' =\u003e '400',\n            'raw': \"l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end\"\n        ]\n    ]\n));\n```\n#### Sample Result URL\n```\nhttps://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end/img/sample-video.mp4\n```\n\n### 6. Arithmetic expressions in transformations\n\nImageKit allows use of [arithmetic expressions](https://docs.imagekit.io/features/arithmetic-expressions-in-transformations) in certain dimension and position-related parameters, making media transformations more flexible and dynamic.\n\nFor example:\n\n```php\n$imageURL = $imageKit-\u003eurl(array(\n    'path' =\u003e '/default-image.jpg',\n    'urlEndpoint' =\u003e 'https://ik.imagekit.io/your_imagekit_id'\n    'transformation' =\u003e [\n        [\n            \"height\": \"ih_div_2\",\n            \"width\": \"iw_div_4\",\n            \"border\": \"cw_mul_0.05_yellow\"\n        ]\n    ]\n));\n```\n\n#### Sample Result URL\n```\nhttps://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=w-iw_div_4,h-ih_div_2,b-cw_mul_0.05_yellow\n``\n\n### 7. Signed URL\n\nFor example, the signed URL expires in 300 seconds with the default URL endpoint and other query parameters.\nFor a detailed explanation of the signed URL, refer to this [documentation](https://docs.imagekit.io/features/security/signed-urls).\n\n#### Example\n```php  \n$imageURL = $imageKit-\u003eurl([\n    \"path\" =\u003e \"/default-image.jpg\",\n    \"queryParameters\" =\u003e \n    [\n        \"v\" =\u003e \"123\"\n    ],\n    \"transformation\" =\u003e [\n        [\n            \"height\" =\u003e \"300\",\n            \"width\" =\u003e \"400\"\n        ]\n    ],\n    \"signed\" =\u003e true,\n    \"expireSeconds\" =\u003e 300,\n]);\n```  \n#### Response\n```  \nhttps://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400/default-image.jpg?v=123\u0026ik-t=1654183277\u0026ik-s=f98618f264a9ccb3c017e7b7441e86d1bc9a7ebb\n```  \n\nYou can manage [security settings](https://docs.imagekit.io/features/security#restricting-unsigned-urls) from the dashboard to prevent unsigned URLs usage. In that case, if the URL doesn't have a signature `ik-s` parameter or the signature is invalid, ImageKit will return a forbidden error instead of an actual image.\n\n### List of supported transformations\n\nThe complete list of transformations supported and their usage in ImageKit can be found in the docs for [images](https://docs.imagekit.io/features/image-transformations) and [videos](https://docs.imagekit.io/features/video-transformation). The SDK gives a name to each transformation parameter, making the code simpler, making the code simpler, and readable.\n\nIf a transformation is supported in ImageKit, but a name for it cannot be found in the table below, then use the transformation code from ImageKit docs as the name when using the `url` function.\n\nIf you want to generate transformations in your application and add them to the URL as it is, use the `raw` parameter.\n\n| Supported Transformation Name | Translates to parameter |\n|-------------------------------|-------------------------|\n| height | h |\n| width | w |\n| aspectRatio | ar |\n| quality | q |\n| crop | c |\n| cropMode | cm |\n| x | x |\n| y | y |\n| focus | fo |\n| format | f |\n| radius | r |\n| background | bg |\n| border | b |\n| rotation | rt |\n| blur | bl |\n| named | n |\n| progressive | pr |\n| lossless | lo |\n| trim | t |\n| metadata | md |\n| colorProfile | cp |\n| defaultImage | di |\n| dpr | dpr |\n| effectSharpen | e-sharpen |\n| effectUSM | e-usm |\n| effectContrast | e-contrast |\n| effectGray | e-grayscale |\n| effectShadow | e-shadow |\n| effectGradient | e-gradient |\n| original | orig |\n| raw | `replaced by the parameter value` |\n\n\n## Server-side File Upload\n\nThe SDK provides a simple interface using the `$imageKit-\u003euploadFile()` method to upload files to the [ImageKit Media Library](https://imagekit.io/dashboard/media-library). \n\n- [Server-side file upload API](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload).\n- [Supported file types and extensions](https://docs.imagekit.io/api-reference/upload-file-api#allowed-file-types-for-uploading).\n\n#### Basic Usage\n```php\n$uploadFile = $imageKit-\u003euploadFile([\n    'file' =\u003e 'your_file',              //  required, \"binary\",\"base64\" or \"file url\"\n    'fileName' =\u003e 'your_file_name.jpg', //  required\n    'checks' =\u003e '\"file.size\" \u003c \"1mb\"',  //  optional `checks` parameters can be used to run server-side checks before files are uploaded to the Media Library.\n]);\n```\n#### Response\n```json\n{\n    \"error\": null,\n    \"result\": {\n        \"fileId\": \"6286329dfef1b033aee60211\",\n        \"name\": \"your_file_name_S-PgGysnR.jpg\",\n        \"size\": 94466,\n        \"versionInfo\": {\n            \"id\": \"6286329dfef1b033aee60211\",\n            \"name\": \"Version 1\"\n        },\n        \"filePath\": \"/your_file_name_S-PgGysnR.jpg\",\n        \"url\": \"https://ik.imagekit.io/demo/your_file_name_S-PgGysnR.jpg\",\n        \"fileType\": \"image\",\n        \"height\": 640,\n        \"width\": 960,\n        \"thumbnailUrl\": \"https://ik.imagekit.io/demo/tr:n-ik_ml_thumbnail/your_file_name_S-PgGysnR.jpg\",\n        \"tags\": [],\n        \"AITags\": null,\n        \"customMetadata\": { },\n        \"extensionStatus\": {}\n    },\n    \"responseMetadata\":{\n        \"headers\":{\n            \"access-control-allow-origin\": \"*\",\n            \"x-ik-requestid\": \"e98f2464-2a86-4934-a5ab-9a226df012c9\",\n            \"content-type\": \"application/json; charset=utf-8\",\n            \"content-length\": \"434\",\n            \"etag\": 'W/\"1b2-reNzjRCFNt45rEyD7yFY/dk+Ghg\"',\n            \"date\": \"Thu, 16 Jun 2022 14:22:01 GMT\",\n            \"x-request-id\": \"e98f2464-2a86-4934-a5ab-9a226df012c9\"\n        },\n        \"raw\":{\n            \"fileId\": \"6286329dfef1b033aee60211\",\n            \"name\": \"your_file_name_S-PgGysnR.jpg\",\n            \"size\": 94466,\n            \"versionInfo\": {\n                \"id\": \"6286329dfef1b033aee60211\",\n                \"name\": \"Version 1\"\n            },\n            \"filePath\": \"/your_file_name_S-PgGysnR.jpg\",\n            \"url\": \"https://ik.imagekit.io/demo/your_file_name_S-PgGysnR.jpg\",\n            \"fileType\": \"image\",\n            \"height\": 640,\n            \"width\": 960,\n            \"thumbnailUrl\": \"https://ik.imagekit.io/demo/tr:n-ik_ml_thumbnail/your_file_name_S-PgGysnR.jpg\",\n            \"tags\": [],\n            \"AITags\": null,\n            \"customMetadata\": { },\n            \"extensionStatus\": {}\n        },\n        \"statusCode\":200\n    }\n}\n```\n#### Optional Parameters\nPlease refer to [server-side file upload API request structure](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload#request-structure-multipart-form-data) for a detailed explanation of mandatory and optional parameters.\n\n```php\n// Attempt File Uplaod\n$uploadFile = $imageKit-\u003euploadFile([\n    'file' =\u003e 'your_file',                  //  required, \"binary\",\"base64\" or \"file url\"\n    'fileName' =\u003e 'your_file_name.jpg',     //  required\n    // Optional Parameters\n    \"useUniqueFileName\" =\u003e true,            // true|false\n    \"tags\" =\u003e implode(\",\",[\"abd\", \"def\"]),  // max: 500 chars\n    \"folder\" =\u003e \"/sample-folder\",           \n    \"isPrivateFile\" =\u003e false,               // true|false\n    \"customCoordinates\" =\u003e implode(\",\", [\"10\", \"10\", \"100\", \"100\"]),    // max: 500 chars\n    \"responseFields\" =\u003e implode(\",\", [\"tags\", \"customMetadata\"]),\n    \"extensions\" =\u003e [       \n        [\n            \"name\" =\u003e \"remove-bg\",\n            \"options\" =\u003e [  // refer https://docs.imagekit.io/extensions/overview\n                \"add_shadow\" =\u003e true\n            ]\n        ]\n    ],\n    \"webhookUrl\" =\u003e \"https://example.com/webhook\",\n    \"overwriteFile\" =\u003e true,        // in case of false useUniqueFileName should be true\n    \"overwriteAITags\" =\u003e true,      // set to false in order to preserve overwriteAITags\n    \"overwriteTags\" =\u003e true,\n    \"overwriteCustomMetadata\" =\u003e true,\n    'transformation' =\u003e [ \n        'pre' =\u003e 'l-text,i-Imagekit,fs-50,l-end', \n        'post' =\u003e [\n            [ \n                'type' =\u003e 'transformation', \n                'value' =\u003e 'h-100' \n            ]\n        ]\n    ],\n    'checks' =\u003e '\"file.size\" \u003c \"1mb\"',  //  optional `checks` parameters can be used to run server-side checks before files are uploaded to the Media Library.\n    'isPublished' =\u003e true,\n    // \"customMetadata\" =\u003e [\n    //         \"SKU\" =\u003e \"VS882HJ2JD\",\n    //         \"price\" =\u003e 599.99,\n    // ]\n]);\n```  \n\n## File Management\n\nThe SDK provides a simple interface for all the following [Media APIs](https://docs.imagekit.io/api-reference/media-api) to manage your files.\n\n### 1. List and Search Files\n\nThis API can list all the uploaded files and folders in your [ImageKit.io](https://docs.imagekit.io/api-reference/media-api) media library. \n\nRefer to the [list and search file API](https://docs.imagekit.io/api-reference/media-api/list-and-search-files) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$listFiles = $imageKit-\u003elistFiles();\n```\n#### Applying Filters\nFilter out the files with an object specifying the parameters. \n\n```php\n$listFiles = $imageKit-\u003elistFiles([\n    \"type\" =\u003e \"file\",           // file, file-version or folder\n    \"sort\" =\u003e \"ASC_CREATED\",    \n    \"path\" =\u003e \"/\",              // folder path\n    \"fileType\" =\u003e \"all\",        // all, image, non-image\n    \"limit\" =\u003e 10,              // min:1, max:1000\n    \"skip\" =\u003e 0,                // min:0\n]);\n```\n\n#### Advance Search\nIn addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and providing this generated string as the value of the `searchQuery`.\n\n```php\n$listFiles = $imageKit-\u003elistFiles([\n    \"searchQuery\" =\u003e '(size \u003c \"1mb\" AND width \u003e 500) OR (tags IN [\"summer-sale\",\"banner\"])',\n]);\n```\nDetailed documentation can be found here for [advance search queries](https://docs.imagekit.io/api-reference/media-api/list-and-search-files#advanced-search-queries).\n\n### 2. Get File Details\n\nThis API will get all the details and attributes of the current version of the asset.\n\nRefer to the [get file details API](https://docs.imagekit.io/api-reference/media-api/get-file-details) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$getFileDetails = $imageKit-\u003egetFileDetails('file_id');\n```\n\n### 3. Get File Version Details\n\nThis API can get you all the details and attributes for the provided version of the file.\n\nRefer to the [get file version details API](https://docs.imagekit.io/api-reference/media-api/get-file-version-details) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$getFileVersionDetails = $imageKit-\u003egetFileVersionDetails('file_id','version_id');\n```\n\n### 4. Get File Versions\n\nThis API will get you all the versions of an asset.\n\nRefer to the [get file versions API](https://docs.imagekit.io/api-reference/media-api/get-file-versions) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$getFileVersions = $imageKit-\u003egetFileVersions('file_id');\n```\n\n### 5. Update File Details\n\nUpdate file details such as `tags`, `customCoordinates` attributes, remove existing `AITags`, and apply [extensions](https://docs.imagekit.io/extensions/overview) using update file details API. This operation can only be performed only on the current version of an asset.\n\nRefer to the [update file details API](https://docs.imagekit.io/api-reference/media-api/update-file-details) for better understanding about the **request \u0026 response structure**.\n\n#### Example\n```php\n// Update parameters\n$updateData = [\n        \"removeAITags\" =\u003e \"all\",    // \"all\" or [\"tag1\",\"tag2\"]\n        \"webhookUrl\" =\u003e \"https://example.com/webhook\",\n        \"extensions\" =\u003e [       \n            [\n                \"name\" =\u003e \"remove-bg\",\n                \"options\" =\u003e [  // refer https://docs.imagekit.io/extensions/overview\n                    \"add_shadow\" =\u003e true\n                ]\n            ],\n            [\n                \"name\" =\u003e \"google-auto-tagging\",\n            ]\n        ],\n        \"tags\" =\u003e [\"tag1\", \"tag2\"],\n        \"customCoordinates\" =\u003e \"10,10,100,100\",\n        // \"customMetadata\" =\u003e [\n        //     \"SKU\" =\u003e \"VS882HJ2JD\",\n        //     \"price\" =\u003e 599.99,\n        // ]\n];\n\n// Attempt Update\n$updateFileDetails = $imageKit-\u003eupdateFileDetails(\n    'file_id',\n    $updateData\n);\n```\n\n**Update publish status**\n\nIf `publish` is included in the update options, no other parameters are allowed. If any are present, an error will be returned: `Your request cannot contain any other parameters when publish is present`.\n\n#### Example\n```php\n// Update parameters\n$updateData = [\n    \"publish\" =\u003e [\n        \"isPublished\" =\u003e true,\n        \"includeFileVersions\" =\u003e true\n    ]\n];\n\n// Attempt Update\n$updateFileDetails = $imageKit-\u003eupdateFileDetails(\n    'file_id',\n    $updateData\n);\n```\n\n### 6. Add Tags (Bulk) API\n\nAdd tags to multiple files in a single request. The method accepts an array of `fileIds` of the files and an array of `tags` that have to be added to those files.\n\nRefer to the [add tags (Bulk) API](https://docs.imagekit.io/api-reference/media-api/add-tags-bulk) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$fileIds = ['file_id1','file_id2'];\n$tags = ['image_tag_1', 'image_tag_2'];\n\n$bulkAddTags = $imageKit-\u003ebulkAddTags($fileIds, $tags);\n```\n\n### 7. Remove Tags (Bulk) API\n\nRemove tags from multiple files in a single request. The method accepts an array of `fileIds` of the files and an array of `tags` that have to be removed from those files.\n\nRefer to the [remove tags (Bulk) API](https://docs.imagekit.io/api-reference/media-api/remove-tags-bulk) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$fileIds = ['file_id1','file_id2'];\n$tags = ['image_tag_1', 'image_tag_2'];\n\n$bulkRemoveTags = $imageKit-\u003ebulkRemoveTags($fileIds, $tags);\n```\n\n### 8. Remove AI Tags (Bulk) API\n\nRemove AI tags from multiple files in a single request. The method accepts an array of `fileIds` of the files and an array of `AITags` that have to be removed from those files.\n\nRefer to the [remove AI Tags (Bulk) API](https://docs.imagekit.io/api-reference/media-api/remove-aitags-bulk) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$fileIds = ['file_id1','file_id2'];\n$AITags = ['image_AITag_1', 'image_AITag_2'];\n\n$bulkRemoveTags = $imageKit-\u003ebulkRemoveTags($fileIds, $AITags);\n```\n\n### 9. Delete File API\n\nYou can programmatically delete uploaded files in the media library using delete file API.\n\n\u003e If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. However, you can purge the cache using [Purge Cache API](#21-purge-cache-api).\n\nRefer to the [delete file API](https://docs.imagekit.io/api-reference/media-api/delete-file) for better understanding about the **request \u0026 response structure**.\n\n#### Basic Usage\n```php\n$fileId = 'file_id';\n$deleteFile = $imageKit-\u003edeleteFile($fileId);\n```\n\n### 10. Delete File Version API\n\nUsing the delete file version API, you can programmatically delete the uploaded file version in the media library.\n\n\u003e You can delete only the non-current version of a file.\n\nRefer to the [delete file version API](https://docs.imagekit.io/api-reference/media-api/delete-file-version) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$fileId = 'file_id';\n$versionId = 'version_id';\n$deleteFileVersion = $imageKit-\u003edeleteFileVersion($fileId, $versionId);\n```\n\n### 11. Delete Files (Bulk) API\n\nDeletes multiple files and their versions from the media library.\n\nRefer to the [delete files (Bulk) API](https://docs.imagekit.io/api-reference/media-api/delete-files-bulk) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$fileIds = [\"5e1c13d0c55ec3437c451406\", ...];\n$deleteFiles = $imageKit-\u003ebulkDeleteFiles($fileIds);\n```\n\n\n### 12. Copy File API\n\nThis will copy a file from one folder to another.\n\n\u003e  If any file at the destination has the same name as the source file, then the source file and its versions (if `includeFileVersions` is set to true) will be appended to the destination file version history.\n\nRefer to the [copy file API](https://docs.imagekit.io/api-reference/media-api/copy-file) for a better understanding of the **request \u0026 response structure**.\n\n#### Basic Usage\n```php\n$sourceFilePath = '/sample-folder1/sample-file.jpg';\n$destinationPath = '/sample-folder2/';\n$includeFileVersions = false;\n\n$copyFile = $imageKit-\u003ecopy([\n    'sourceFilePath' =\u003e $sourceFilePath,\n    'destinationPath' =\u003e $destinationPath,\n    'includeFileVersions' =\u003e $includeFileVersions\n]);\n```\n\n### 13. Move File API\n\nThis will move a file and all its versions from one folder to another.\n\n\u003e  If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file.\n\nRefer to the [move file API](https://docs.imagekit.io/api-reference/media-api/move-file) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$sourceFilePath = '/sample-file.jpg';\n$destinationPath = '/sample-folder/';\n\n$moveFile = $imageKit-\u003emove([\n    'sourceFilePath' =\u003e $sourceFilePath,\n    'destinationPath' =\u003e $destinationPath\n]);\n```\n\n### 14. Rename File API\n\nUsing Rename File API, you can programmatically rename an already existing file in the media library. This operation would rename all versions of the file.\n\n\u003e  The old URLs will stop working. However, the file/file version URLs cached on CDN will continue to work unless a purge is requested.\n\nRefer to the [rename file API](https://docs.imagekit.io/api-reference/media-api/rename-file) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n// Purge Cache would default to false\n\n$filePath = '/sample-folder/sample-file.jpg';\n$newFileName = 'sample-file2.jpg';\n$renameFile = $imageKit-\u003erename([\n    'filePath' =\u003e $filePath,\n    'newFileName' =\u003e $newFileName,\n]);\n```\nWhen `purgeCache` is set to `true`, response will return `purgeRequestId`. This `purgeRequestId` can be used to get the purge request status.\n```php\n$filePath = '/sample-folder/sample-file.jpg';\n$newFileName = 'sample-file2.jpg';\n$renameFile = $imageKit-\u003erename([\n    'filePath' =\u003e $filePath,\n    'newFileName' =\u003e $newFileName,\n],true);\n```\n\n### 15. Restore File Version API\n\nThis will restore the provided file version to a different version of the file. The newly restored version of the file will be returned in the response.\n\nRefer to the [restore file version API](https://docs.imagekit.io/api-reference/media-api/restore-file-version) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$fileId = 'fileId';\n$versionId = 'versionId';\n$restoreFileVersion = $imageKit-\u003erestoreFileVersion([\n    'fileId' =\u003e $fileId,\n    'versionId' =\u003e $versionId,\n]);\n```\n\n### 16. Create Folder API\n\nThis will create a new folder. You can specify the folder name and location of the parent folder where this new folder should be created.\n\nRefer to the [create folder API](https://docs.imagekit.io/api-reference/media-api/create-folder) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$folderName = 'new-folder';\n$parentFolderPath = '/';\n$createFolder = $imageKit-\u003ecreateFolder([\n    'folderName' =\u003e $folderName,\n    'parentFolderPath' =\u003e $parentFolderPath,\n]);\n```\n\n### 17. Delete Folder API\n\nThis will delete the specified folder and all nested files, their versions \u0026 folders. This action cannot be undone.\n\nRefer to the [delete folder API](https://docs.imagekit.io/api-reference/media-api/delete-folder) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$folderPath = '/new-folder';\n$deleteFolder = $imageKit-\u003edeleteFolder($folderPath);\n```\n\n### 18. Copy Folder API\n\nThis will copy one folder into another.\n\nRefer to the [copy folder API](https://docs.imagekit.io/api-reference/media-api/copy-folder) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$sourceFolderPath = '/source-folder/';\n$destinationPath = '/destination-folder/';\n$includeFileVersions = false;\n$copyFolder = $imageKit-\u003ecopyFolder([\n    'sourceFolderPath' =\u003e $sourceFolderPath,\n    'destinationPath' =\u003e $destinationPath,\n    'includeFileVersions' =\u003e $includeFileVersions\n]);\n```\n\n### 19. Move Folder API\n\nThis will move one folder into another. The selected folder, its nested folders, files, and their versions are moved in this operation.\n\n\u003e If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n\nRefer to the [move folder API](https://docs.imagekit.io/api-reference/media-api/move-folder) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$sourceFolderPath = '/sample-folder/';\n$destinationPath = '/destination-folder/';\n$moveFolder = $imageKit-\u003emoveFolder([\n    'sourceFolderPath' =\u003e $sourceFolderPath,\n    'destinationPath' =\u003e $destinationPath\n]);\n```\n\n### 20. Bulk Job Status API\n\nThis endpoint allows you to get the status of a bulk operation e.g. [Copy Folder API](#18-copy-folder-api) or [Move Folder API](#19-move-folder-api).\n\nRefer to the [bulk job status API](https://docs.imagekit.io/api-reference/media-api/copy-move-folder-status) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$jobId = 'jobId';\n$bulkJobStatus = $imageKit-\u003egetBulkJobStatus($jobId);\n```\n\n### 21. Purge Cache API\n\nThis will purge CDN and ImageKit.io's internal cache. In response, `requestId` is returned, which can be used to fetch the status of the submitted purge request with [Purge Cache Status API](#22-purge-cache-status-api).\n\nRefer to the [Purge Cache API](https://docs.imagekit.io/api-reference/media-api/purge-cache) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$image_url = 'https://ik.imagekit.io/demo/sample-folder/sample-file.jpg';\n$purgeCache = $imageKit-\u003epurgeCache($image_url);\n```\n\nYou can purge the cache for multiple files. Check [purge cache multiple files](https://docs.imagekit.io/api-reference/media-api/purge-cache#purge-cache-for-multiple-files).\n\n### 22. Purge Cache Status API\n\nGet the purge cache request status using the `requestId` returned when a purge cache request gets submitted with [Purge Cache API](#21-purge-cache-api)\n\nRefer to the [Purge Cache Status API](https://docs.imagekit.io/api-reference/media-api/purge-cache-status) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$cacheRequestId = '598821f949c0a938d57563bd';\n$purgeCacheStatus = $imageKit-\u003epurgeCacheStatus($cacheRequestId);\n```\n\n### 23. Get File Metadata API (From File ID)\n\nGet the image EXIF, pHash, and other metadata for uploaded files in the ImageKit.io media library using this API.\n\nRefer to the [get image metadata for uploaded media files API](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-for-uploaded-media-files) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$fileId = '598821f949c0a938d57563bd';\n$getFileMetadata = $imageKit-\u003egetFileMetaData($fileId);\n```\n\n### 24. Get File Metadata API (From Remote URL)\n\nGet image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API.\n\nRefer to the [get image metadata from remote URL API](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-from-remote-url) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$image_url = 'https://ik.imagekit.io/demo/sample-folder/sample-file.jpg';\n$getFileMetadataFromRemoteURL = $imageKit-\u003egetFileMetadataFromRemoteURL($image_url);\n```\n## Custom Metadata Fields API\n\nImagekit.io allows you to define a `schema` for your metadata keys, and the value filled against that key will have to adhere to those rules. You can [create](#1-create-fields), [read](#2-get-fields) and [update](#3-update-fields) custom metadata rules and update your file with custom metadata value in [file update API](#5-update-file-details) or [file upload API](#server-side-file-upload).\n\nFor a detailed explanation, refer to the [custom metadata fields documentation](https://docs.imagekit.io/api-reference/custom-metadata-fields-api).\n\n\n### 1. Create Fields\n\nCreate a custom metadata field with this API.\n\nRefer to the [create custom metadata fields API](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/create-custom-metadata-field) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$body = [\n    \"name\" =\u003e \"price\",              // required\n    \"label\" =\u003e \"Unit Price\",        // required\n    \"schema\" =\u003e [                   // required\n        \"type\" =\u003e 'Number',         // required\n        \"minValue\" =\u003e 1000,\n        \"maxValue\" =\u003e 5000,\n    ],\n];\n\n$createCustomMetadataField = $imageKit-\u003ecreateCustomMetadataField($body);\n```\n\nCheck for the [allowed values in the schema](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/create-custom-metadata-field#allowed-values-in-the-schema-object).\n\n### 2. Get Fields\n\nGet a list of all the custom metadata fields.\n\nRefer to the [get custom metadata fields API](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/get-custom-metadata-field) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$includeDeleted = false;\n$getCustomMetadataField = $imageKit-\u003egetCustomMetadataField($includeDeleted);\n```\n\n### 3. Update Fields\n\nUpdate an existing custom metadata field's `label` or `schema`.\n\nRefer to the [update custom metadata fields API](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/update-custom-metadata-field) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$customMetadataFieldId = '598821f949c0a938d57563dd';\n$body = [\n    \"label\" =\u003e \"Net Price\",\n    \"schema\" =\u003e [\n        \"type\"=\u003e'Number'\n    ],\n];\n\n$updateCustomMetadataField = $imageKit-\u003eupdateCustomMetadataField($customMetadataFieldId, $body);\n```\n\nCheck for the [allowed values in the schema](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/create-custom-metadata-field#allowed-values-in-the-schema-object).\n\n\n### 4. Delete Fields\n\nDelete a custom metadata field.\n\nRefer to the [delete custom metadata fields API](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/delete-custom-metadata-field) for a better understanding of the **request \u0026 response structure**.\n\n#### Example\n```php\n$customMetadataFieldId = '598821f949c0a938d57563dd';\n\n$deleteCustomMetadataField = $imageKit-\u003edeleteCustomMetadataField($customMetadataFieldId);\n```\n\n\n## Utility functions\n\nWe have included the following commonly used utility functions in this SDK.\n\n### Authentication parameter generation\n\nIf you want to implement client-side file upload, you will need a `token`, `expiry` timestamp, and a valid `signature` for that upload. The SDK provides a simple method you can use in your code to generate these authentication parameters.\n\n_Note: The Private API Key should never be exposed in any client-side code. You must always generate these authentication parameters on the server-side_\n\n```php  \n$imageKit-\u003egetAuthenticationParameters($token = \"\", $expire = 0);  \n```  \n\nReturns\n\n```json\n{\n    \"token\": \"5d1c4a22-54f2-40bb-9e8c-99daaeeb7307\",\n    \"expire\": 1654207193,\n    \"signature\": \"a03a88b814570a3d92919c16a1b8bd4491f053c3\"\n}\n```  \n\nBoth the `token` and `expire` parameters are optional. If not specified, the SDK internally generates a random token and a valid expiry timestamp. The value of the `token` and `expire` used to create the signature is always returned in the response, whether they are provided in input or not.\n\n### Distance calculation between two pHash values\n\nPerceptual hashing allows you to construct a hash value that uniquely identifies an input image based on the contents of an image. [ImageKit.io metadata API](https://docs.imagekit.io/api-reference/metadata-api) returns the pHash value of an image in the response. You can use this value to find a duplicate (or similar) image by calculating the distance between the pHash value of the two images.\n\nThis SDK exposes `pHashDistance` function to calculate the distance between two pHash values. It accepts two pHash hexadecimal strings and returns a numeric value indicative of the level of difference between the two images.\n\n```php  \n $imageKit-\u003epHashDistance($firstHash ,$secondHash);  \n```  \n\n#### Distance calculation examples\n\n```php  \n$imageKit-\u003epHashDistance('f06830ca9f1e3e90', 'f06830ca9f1e3e90');  \n// output: 0 (same image)  \n  \n$imageKit-\u003epHashDistance('2d5ad3936d2e015b', '2d6ed293db36a4fb');  \n// output: 17 (similar images)  \n  \n$imageKit-\u003epHashDistance('a4a65595ac94518b', '7838873e791f8400');  \n// output: 37 (dissimilar images)  \n```  \n\n## Opening Issues\nIf you encounter a bug with `imagekit-php` we would like to hear about it. Search the existing issues and try to make sure your problem doesn't already exist before opening a new issue. It's helpful if you include the version of `imagekit-php`, PHP version, and OS you're using. Please include a stack trace and a simple workflow to reproduce the case when appropriate, too.\n\n\n## Support\n\nFor any feedback or to report any issues or general implementation support, please reach out to [support@imagekit.io](mailto:support@imagekit.io)\n\n## Resources\n\n- [Main website](https://imagekit.io) - Main Website.\n- [Documentation](https://docs.imagekit.io) - For both getting started and in-depth SDK usage information.\n- [PHP quick start guide](https://docs.imagekit.io/getting-started/quickstart-guides/php)\n\n## License\n\nReleased under the MIT license.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimagekit-developer%2Fimagekit-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimagekit-developer%2Fimagekit-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimagekit-developer%2Fimagekit-php/lists"}