Skip to content

Add inc/dec #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# Change Log
# Change Log

## 15.1.0

* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service
* Add `dart38` and `flutter332` support to runtime models
* Add `gif` support to `ImageFormat` enum
* Add `upsertDocument` support to `Databases` service
* Add `sequence` support to `Document` model
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Appwrite PHP SDK

![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1)
![Version](https://img.shields.io/badge/api%20version-1.7.0-blue.svg?style=flat-square&v=1)
![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square&v=1)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
Expand Down
73 changes: 68 additions & 5 deletions docs/databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,9 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection
POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents
```

** Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. **
** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.

Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. **

### Parameters

Expand All @@ -638,7 +640,9 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection
PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents
```

** Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.
** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.

Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.
**

### Parameters
Expand All @@ -647,14 +651,16 @@ PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI
| --- | --- | --- | --- |
| databaseId | string | **Required** Database ID. | |
| collectionId | string | **Required** Collection ID. | |
| documents | array | Array of document data as JSON objects. May contain partial documents. | [] |
| documents | array | Array of document data as JSON objects. May contain partial documents. | |


```http request
PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents
```

** Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. **
** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.

Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. **

### Parameters

Expand All @@ -670,7 +676,9 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio
DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents
```

** Bulk delete documents using queries, if no queries are passed then all documents are deleted. **
** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.

Bulk delete documents using queries, if no queries are passed then all documents are deleted. **

### Parameters

Expand All @@ -697,6 +705,25 @@ GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI
| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] |


```http request
PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId}
```

** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.

Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. **

### Parameters

| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| databaseId | string | **Required** Database ID. | |
| collectionId | string | **Required** Collection ID. | |
| documentId | string | **Required** Document ID. | |
| data | object | Document data as JSON object. Include all required attributes of the document to be created or updated. | {} |
| permissions | array | An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | |


```http request
PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId}
```
Expand Down Expand Up @@ -729,6 +756,42 @@ DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collecti
| documentId | string | **Required** Document ID. | |


```http request
PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement
```

** Decrement a specific attribute of a document by a given value. **

### Parameters

| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| databaseId | string | **Required** Database ID. | |
| collectionId | string | **Required** Collection ID. | |
| documentId | string | **Required** Document ID. | |
| attribute | string | **Required** Attribute key. | |
| value | number | Value to decrement the attribute by. The value must be a number. | 1 |
| min | number | Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. | |


```http request
PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment
```

** Increment a specific attribute of a document by a given value. **

### Parameters

| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| databaseId | string | **Required** Database ID. | |
| collectionId | string | **Required** Collection ID. | |
| documentId | string | **Required** Document ID. | |
| attribute | string | **Required** Attribute key. | |
| value | number | Value to increment the attribute by. The value must be a number. | 1 |
| max | number | Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. | |


```http request
GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/indexes
```
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/databases/create-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ use Appwrite\Services\Databases;

$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
->setSession('') // The user session to authenticate with
->setKey('<YOUR_API_KEY>') // Your secret API key
->setJWT('<YOUR_JWT>'); // Your secret JSON Web Token
->setProject('<YOUR_PROJECT_ID>') // Your project ID
->setSession(''); // The user session to authenticate with

$databases = new Databases($client);

Expand Down
1 change: 1 addition & 0 deletions docs/examples/databases/create-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use Appwrite\Services\Databases;

$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
->setProject('<YOUR_PROJECT_ID>') // Your project ID
->setKey('<YOUR_API_KEY>'); // Your secret API key

$databases = new Databases($client);
Expand Down
20 changes: 20 additions & 0 deletions docs/examples/databases/decrement-document-attribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

use Appwrite\Client;
use Appwrite\Services\Databases;

$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
->setProject('<YOUR_PROJECT_ID>') // Your project ID
->setKey('<YOUR_API_KEY>'); // Your secret API key

$databases = new Databases($client);

$result = $databases->decrementDocumentAttribute(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>',
attribute: '',
value: null, // optional
min: null // optional
);
20 changes: 20 additions & 0 deletions docs/examples/databases/increment-document-attribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

use Appwrite\Client;
use Appwrite\Services\Databases;

$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
->setProject('<YOUR_PROJECT_ID>') // Your project ID
->setKey('<YOUR_API_KEY>'); // Your secret API key

$databases = new Databases($client);

$result = $databases->incrementDocumentAttribute(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>',
attribute: '',
value: null, // optional
max: null // optional
);
19 changes: 19 additions & 0 deletions docs/examples/databases/upsert-document.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use Appwrite\Client;
use Appwrite\Services\Databases;

$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
->setProject('<YOUR_PROJECT_ID>') // Your project ID
->setSession(''); // The user session to authenticate with

$databases = new Databases($client);

$result = $databases->upsertDocument(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>',
data: [],
permissions: ["read("any")"] // optional
);
2 changes: 1 addition & 1 deletion docs/examples/databases/upsert-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ $databases = new Databases($client);
$result = $databases->upsertDocuments(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documents: [] // optional
documents: []
);
2 changes: 1 addition & 1 deletion docs/tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ GET https://cloud.appwrite.io/v1/tokens/buckets/{bucketId}/files/{fileId}
POST https://cloud.appwrite.io/v1/tokens/buckets/{bucketId}/files/{fileId}
```

** Create a new token. A token is linked to a file. Token can be passed as a header or request get parameter. **
** Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. **

### Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ GET https://cloud.appwrite.io/v1/users/{userId}/targets
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| userId | string | **Required** User ID. | |
| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels | [] |
| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, providerId, identifier, providerType | [] |


```http request
Expand Down
4 changes: 2 additions & 2 deletions src/Appwrite/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class Client
*/
protected array $headers = [
'content-type' => '',
'user-agent' => 'AppwritePHPSDK/15.0.0 ()',
'user-agent' => 'AppwritePHPSDK/15.1.0 ()',
'x-sdk-name'=> 'PHP',
'x-sdk-platform'=> 'server',
'x-sdk-language'=> 'php',
'x-sdk-version'=> '15.0.0',
'x-sdk-version'=> '15.1.0',
];

/**
Expand Down
16 changes: 16 additions & 0 deletions src/Appwrite/Enums/BuildRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class BuildRuntime implements JsonSerializable
private static BuildRuntime $DART31;
private static BuildRuntime $DART33;
private static BuildRuntime $DART35;
private static BuildRuntime $DART38;
private static BuildRuntime $DOTNET60;
private static BuildRuntime $DOTNET70;
private static BuildRuntime $DOTNET80;
Expand All @@ -69,6 +70,7 @@ class BuildRuntime implements JsonSerializable
private static BuildRuntime $FLUTTER324;
private static BuildRuntime $FLUTTER327;
private static BuildRuntime $FLUTTER329;
private static BuildRuntime $FLUTTER332;

private string $value;

Expand Down Expand Up @@ -346,6 +348,13 @@ public static function DART35(): BuildRuntime
}
return self::$DART35;
}
public static function DART38(): BuildRuntime
{
if (!isset(self::$DART38)) {
self::$DART38 = new BuildRuntime('dart-3.8');
}
return self::$DART38;
}
public static function DOTNET60(): BuildRuntime
{
if (!isset(self::$DOTNET60)) {
Expand Down Expand Up @@ -528,4 +537,11 @@ public static function FLUTTER329(): BuildRuntime
}
return self::$FLUTTER329;
}
public static function FLUTTER332(): BuildRuntime
{
if (!isset(self::$FLUTTER332)) {
self::$FLUTTER332 = new BuildRuntime('flutter-3.32');
}
return self::$FLUTTER332;
}
}
8 changes: 8 additions & 0 deletions src/Appwrite/Enums/ImageFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ImageFormat implements JsonSerializable
private static ImageFormat $WEBP;
private static ImageFormat $HEIC;
private static ImageFormat $AVIF;
private static ImageFormat $GIF;

private string $value;

Expand Down Expand Up @@ -72,4 +73,11 @@ public static function AVIF(): ImageFormat
}
return self::$AVIF;
}
public static function GIF(): ImageFormat
{
if (!isset(self::$GIF)) {
self::$GIF = new ImageFormat('gif');
}
return self::$GIF;
}
}
16 changes: 16 additions & 0 deletions src/Appwrite/Enums/Runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Runtime implements JsonSerializable
private static Runtime $DART31;
private static Runtime $DART33;
private static Runtime $DART35;
private static Runtime $DART38;
private static Runtime $DOTNET60;
private static Runtime $DOTNET70;
private static Runtime $DOTNET80;
Expand All @@ -69,6 +70,7 @@ class Runtime implements JsonSerializable
private static Runtime $FLUTTER324;
private static Runtime $FLUTTER327;
private static Runtime $FLUTTER329;
private static Runtime $FLUTTER332;

private string $value;

Expand Down Expand Up @@ -346,6 +348,13 @@ public static function DART35(): Runtime
}
return self::$DART35;
}
public static function DART38(): Runtime
{
if (!isset(self::$DART38)) {
self::$DART38 = new Runtime('dart-3.8');
}
return self::$DART38;
}
public static function DOTNET60(): Runtime
{
if (!isset(self::$DOTNET60)) {
Expand Down Expand Up @@ -528,4 +537,11 @@ public static function FLUTTER329(): Runtime
}
return self::$FLUTTER329;
}
public static function FLUTTER332(): Runtime
{
if (!isset(self::$FLUTTER332)) {
self::$FLUTTER332 = new Runtime('flutter-3.32');
}
return self::$FLUTTER332;
}
}
Loading