You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-15Lines changed: 20 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@
5
5
6
6
PHP SDK for [ImageKit](https://imagekit.io/) implements the new APIs and interface for different file operations.
7
7
8
-
ImageKit is complete media storage, optimization, and transformation solution that comes with an [image and video CDN](https://imagekit.io/features/imagekit-infrastructure). 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.
8
+
ImageKit 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.
9
9
10
10
-[Key Features](#key-features)
11
11
-[Requirements](#requirements)
@@ -80,6 +80,7 @@ You can use this PHP SDK for three different methods - URL generation, file uplo
80
80
5.**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).
81
81
82
82
## Quick Examples
83
+
83
84
#### Create an ImageKit Instance
84
85
```php
85
86
// Require the Composer autoloader.
@@ -108,13 +109,14 @@ echo $imageURL;
108
109
```php
109
110
// For File Upload
110
111
$uploadFile = $imageKit->uploadFile([
111
-
'file' => 'file-url',
112
-
'fileName' => 'new-file'
112
+
'file' => 'file-url', # required, "binary","base64" or "file url"
113
+
'fileName' => 'new-file' # required
113
114
]);
114
115
```
115
116
116
117
#### Response Structure
117
118
Following 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)
119
+
118
120
```json
119
121
{
120
122
"error": null,
@@ -184,9 +186,10 @@ Following is the response for [server-side file upload API](https://docs.imageki
184
186
185
187
### Using relative file path and URL endpoint
186
188
187
-
This 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.
189
+
This 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.
188
190
189
191
#### Example
192
+
190
193
```php
191
194
$imageURL = $imageKit->url(
192
195
[
@@ -236,7 +239,7 @@ The `$imageKit->url()` method accepts the following parameters.
236
239
| 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. |
237
240
| 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. |
238
241
| 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. |
239
-
| transformationPosition | Optional. The default value is `path`that 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. If you use the `src` parameter to create the URL, the transformation string is always added as a query parameter. |
242
+
| 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. |
240
243
| 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. |
241
244
| 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. |
242
245
| 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.
Let's resize the image to `width` 400 and `height` 300.
323
-
Check detailed instructions on [resize, crop and other Common transformations](https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations)
326
+
Check detailed instructions on [resize, crop, and other Common transformations](https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations)
Please 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 detailed explanation about mandatory and optional parameters.
561
-
```php
563
+
Please 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.
562
564
565
+
```php
563
566
// Attempt File Uplaod
564
567
$uploadFile = $imageKit->uploadFile([
565
568
'file' => 'your_file', // required, "binary","base64" or "file url"
In 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`.
628
+
624
629
```php
625
630
$listFiles = $imageKit->listFiles([
626
631
"searchQuery" => '(size < "1mb" AND width > 500) OR (tags IN ["summer-sale","banner"])',
This API can get you all the details and attributes for the provided version of the file.`versionID` is returned in list file API response.
649
+
This API can get you all the details and attributes for the provided version of the file.
645
650
646
651
Refer 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 & response structure**.
You can programmatically delete uploaded files in the media library using delete file API.
747
752
748
-
> 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. You can purge the cache using [Purge Cache API](#21-purge-cache-api).
753
+
> 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).
749
754
750
755
Refer to the [delete file API](https://docs.imagekit.io/api-reference/media-api/delete-file) for better understanding about the **request & response structure**.
This 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).
954
+
This 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).
950
955
951
956
Refer to the [Purge Cache API](https://docs.imagekit.io/api-reference/media-api/purge-cache) for a better understanding of the **request & response structure**.
Update the `label` or `schema` of an existing custom metadata field.
1045
+
Update an existing custom metadata field's `label` or `schema`.
1041
1046
1042
1047
Refer 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 & response structure**.
1043
1048
@@ -1077,7 +1082,7 @@ We have included the following commonly used utility functions in this SDK.
1077
1082
1078
1083
### Authentication parameter generation
1079
1084
1080
-
If you are looking 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 that you can use in your code to generate these authentication parameters for you.
1085
+
If 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.
1081
1086
1082
1087
_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_
1083
1088
@@ -1095,7 +1100,7 @@ Returns
1095
1100
}
1096
1101
```
1097
1102
1098
-
Both the `token` and `expire` parameters are optional. If not specified, the SDK generates a random token and also generates a valid expiry timestamp internally. 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.
1103
+
Both 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.
If 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.
1129
+
If 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.
0 commit comments