Skip to content
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: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log

## 30.0.0

* Stable release of the dedicated database APIs: `mysql`, `postgresql`, `mongo`, `documentsDB`, and `vectorsDB` services, previously released as release candidates
* Breaking: `tablesDB.cutoverMigration` is renamed to `tablesDB.createCutover`
* Added: Cloudflare and Resend OAuth providers
* Added: `usageAggregateOnlyMetrics` on the `BillingPlan` model
* Fixed: `transactionId` is accepted again by `documentsDB` and `vectorsDB` `createDocument` and `createDocuments`
* Updated: `X-Appwrite-Response-Format` is now `2.0.0`
* Updated: `FrameworkAdapter.fallbackFile` is now optional

## 30.0.0-rc.1

* Breaking: `EmbeddingModel` no longer offers `embedding-gemma` or `bge-small`
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# 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.9.6-blue.svg?style=flat-square&v=1)
![Version](https://img.shields.io/badge/api%20version-2.0.0-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)

**This SDK is compatible with Appwrite server version 1.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).**
**This SDK targets Appwrite server version 1.9.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-php/releases) when APIs differ.

Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the PHP SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)

Expand Down
2 changes: 1 addition & 1 deletion docs/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about

| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| provider | string | **Required** OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. | |
| provider | string | **Required** OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. | |
| success | string | URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. | |
| failure | string | URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. | |
| scopes | array | A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. | [] |
Expand Down
8 changes: 4 additions & 4 deletions docs/avatars.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ GET https://cloud.appwrite.io/v1/avatars/photo

** Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in static fallback.

The photo resolves for the currently authenticated user unless `userId` points at another user. Passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the user's own identity photos, email, and name leave the chain so they never shadow the avatar being asked for. Emails are only ever accepted pre-hashed, so no address ends up in a URL. **
Passing `userId` — `current()` for the authenticated user — resolves the photo from everything known about that user: identity photos, email, and name. An explicit `emailHash` or `name` then overrides just that value, and the user's remaining sources stay in the chain. Without `userId`, passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the session user stays out of the chain so their own photo never shadows the avatar being asked for. When nothing is passed, the photo resolves for the currently authenticated user. Emails are only ever accepted pre-hashed, so no address ends up in a URL. **

### Parameters

Expand All @@ -129,9 +129,9 @@ The photo resolves for the currently authenticated user unless `userId` points a
| quality | integer | Output image quality between 0 and 100. Defaults to 100. | 100 |
| output | string | Output image format. Defaults to 'png'. | png |
| rating | string | Maximum image rating to fetch from Gravatar/Libravatar. Defaults to 'g'. | g |
| userId | string | User ID to resolve the photo for. Defaults to 'current()' for the currently authenticated user. | current() |
| emailHash | string | SHA256 hash of the lowercase, trimmed email address to look up on Gravatar and Libravatar instead of the user's own photo sources. Pass the hash, never the address itself. | |
| name | string | Name to render initials from instead of the user's own photo sources. Max length: 128 chars. | |
| userId | string | User ID to resolve the photo for. Pass 'current()' for the currently authenticated user. When omitted, the session user is used only if no emailHash and no name is passed. | |
| emailHash | string | SHA256 hash of the lowercase, trimmed email address to look up on Gravatar and Libravatar instead of the user's own email. Pass the hash, never the address itself. | |
| name | string | Name to render initials from instead of the user's own name. Max length: 128 chars. | |


```http request
Expand Down
2 changes: 2 additions & 0 deletions docs/documentsdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ POST https://cloud.appwrite.io/v1/documentsdb/{databaseId}/collections/{collecti
| documentId | string | Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | |
| data | object | Document data as JSON object. | {} |
| permissions | array | An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). | |
| transactionId | string | Transaction ID for staging the operation. | |


```http request
Expand All @@ -297,6 +298,7 @@ POST https://cloud.appwrite.io/v1/documentsdb/{databaseId}/collections/{collecti
| databaseId | string | **Required** Database ID. | |
| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. | |
| documents | array | Array of documents data as JSON objects. | [] |
| transactionId | string | Transaction ID for staging the operation. | |


```http request
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/documentsdb/create-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ $result = $documentsDB->createDocument(
'age' => 30,
'isAdmin' => false
],
permissions: [Permission::read(Role::any())] // optional
permissions: [Permission::read(Role::any())], // optional
transactionId: '<TRANSACTION_ID>' // optional
);
```
3 changes: 2 additions & 1 deletion docs/examples/documentsdb/create-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ $documentsDB = new DocumentsDB($client);
$result = $documentsDB->createDocuments(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documents: []
documents: [],
transactionId: '<TRANSACTION_ID>' // optional
);
```
19 changes: 19 additions & 0 deletions docs/examples/project/update-o-auth-2-cloudflare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```php
<?php

use Appwrite\Client;
use Appwrite\Services\Project;

$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

$project = new Project($client);

$result = $project->updateOAuth2Cloudflare(
clientId: '<CLIENT_ID>', // optional
clientSecret: '<CLIENT_SECRET>', // optional
enabled: false // optional
);
```
19 changes: 19 additions & 0 deletions docs/examples/project/update-o-auth-2-resend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```php
<?php

use Appwrite\Client;
use Appwrite\Services\Project;

$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

$project = new Project($client);

$result = $project->updateOAuth2Resend(
clientId: '<CLIENT_ID>', // optional
clientSecret: '<CLIENT_SECRET>', // optional
enabled: false // optional
);
```
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $client = (new Client())

$tablesDB = new TablesDB($client);

$result = $tablesDB->cutoverMigration(
$result = $tablesDB->createCutover(
databaseId: '<DATABASE_ID>',
migrationId: '<MIGRATION_ID>'
);
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/vectorsdb/create-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ $result = $vectorsDB->createDocument(
'key' => 'value'
]
],
permissions: [Permission::read(Role::any())] // optional
permissions: [Permission::read(Role::any())], // optional
transactionId: '<TRANSACTION_ID>' // optional
);
```
3 changes: 2 additions & 1 deletion docs/examples/vectorsdb/create-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ $vectorsDB = new VectorsDB($client);
$result = $vectorsDB->createDocuments(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documents: []
documents: [],
transactionId: '<TRANSACTION_ID>' // optional
);
```
2 changes: 1 addition & 1 deletion docs/mongo.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ DELETE https://cloud.appwrite.io/v1/mongo/{databaseId}/branches/{branchId}
PATCH https://cloud.appwrite.io/v1/mongo/{databaseId}/credentials
```

** Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. **
** Queue a rotation of the primary connection credentials for a dedicated database. A hibernated database is woken by the worker before rotation. List database operations until the returned operation reaches a terminal status, then fetch the database again for the refreshed connection string. **

### Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ DELETE https://cloud.appwrite.io/v1/mysql/{databaseId}/branches/{branchId}
PATCH https://cloud.appwrite.io/v1/mysql/{databaseId}/credentials
```

** Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. **
** Queue a rotation of the primary connection credentials for a dedicated database. A hibernated database is woken by the worker before rotation. List database operations until the returned operation reaches a terminal status, then fetch the database again for the refreshed connection string. **

### Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ DELETE https://cloud.appwrite.io/v1/postgresql/{databaseId}/branches/{branchId}
PATCH https://cloud.appwrite.io/v1/postgresql/{databaseId}/credentials
```

** Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. **
** Queue a rotation of the primary connection credentials for a dedicated database. A hibernated database is woken by the worker before rotation. List database operations until the returned operation reaches a terminal status, then fetch the database again for the refreshed connection string. **

### Parameters

Expand Down
30 changes: 30 additions & 0 deletions docs/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,21 @@ PATCH https://cloud.appwrite.io/v1/project/oauth2/box
| enabled | boolean | OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. | |


```http request
PATCH https://cloud.appwrite.io/v1/project/oauth2/cloudflare
```

** Update the project OAuth2 Cloudflare configuration. **

### Parameters

| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| clientId | string | 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 | |
| clientSecret | string | 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f | |
| enabled | boolean | OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. | |


```http request
PATCH https://cloud.appwrite.io/v1/project/oauth2/dailymotion
```
Expand Down Expand Up @@ -707,6 +722,21 @@ PATCH https://cloud.appwrite.io/v1/project/oauth2/podio
| enabled | boolean | OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. | |


```http request
PATCH https://cloud.appwrite.io/v1/project/oauth2/resend
```

** Update the project OAuth2 Resend configuration. **

### Parameters

| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| clientId | string | 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 | |
| clientSecret | string | 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 | |
| enabled | boolean | OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. | |


```http request
PATCH https://cloud.appwrite.io/v1/project/oauth2/salesforce
```
Expand Down
2 changes: 1 addition & 1 deletion docs/tablesdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/migrations/{migrationI


```http request
POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/migrations/{migrationId}/cutover
POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/migrations/{migrationId}/cutovers
```

** Cut a verified TablesDB migration over to its dedicated compute. Only applies to a migration created with `autoCutover` disabled, which waits at `ready_to_cutover` until this is called. The routing flip happens shortly after this returns, with a brief read-only window. One call buys one attempt: a cutover that fails a check returns the migration to `verifying` and parks it again, so call this once more to retry. **
Expand Down
2 changes: 2 additions & 0 deletions docs/vectorsdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ POST https://cloud.appwrite.io/v1/vectorsdb/{databaseId}/collections/{collection
| documentId | string | Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | |
| data | object | Document data as JSON object. | {} |
| permissions | array | An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). | |
| transactionId | string | Transaction ID for staging the operation. | |


```http request
Expand All @@ -296,6 +297,7 @@ POST https://cloud.appwrite.io/v1/vectorsdb/{databaseId}/collections/{collection
| databaseId | string | **Required** Database ID. | |
| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. | |
| documents | array | Array of documents data as JSON objects. | [] |
| transactionId | string | Transaction ID for staging the operation. | |


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

/**
Expand Down Expand Up @@ -110,7 +110,7 @@ class Client
public function __construct()
{
$this->requestFactory = new RequestFactory();
$this->headers['X-Appwrite-Response-Format'] = '1.9.6';
$this->headers['X-Appwrite-Response-Format'] = '2.0.0';
}

/**
Expand Down
16 changes: 16 additions & 0 deletions src/Appwrite/Enums/OAuthProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class OAuthProvider implements JsonSerializable, Stringable
private static OAuthProvider $BITBUCKET;
private static OAuthProvider $BITLY;
private static OAuthProvider $BOX;
private static OAuthProvider $CLOUDFLARE;
private static OAuthProvider $DAILYMOTION;
private static OAuthProvider $DISCORD;
private static OAuthProvider $DISQUS;
Expand All @@ -40,6 +41,7 @@ class OAuthProvider implements JsonSerializable, Stringable
private static OAuthProvider $PAYPAL;
private static OAuthProvider $PAYPALSANDBOX;
private static OAuthProvider $PODIO;
private static OAuthProvider $RESEND;
private static OAuthProvider $SALESFORCE;
private static OAuthProvider $SLACK;
private static OAuthProvider $SPOTIFY;
Expand Down Expand Up @@ -123,6 +125,12 @@ public static function BOX(): OAuthProvider

return self::$BOX;
}
public static function CLOUDFLARE(): OAuthProvider
{
self::$CLOUDFLARE ??= new OAuthProvider('cloudflare');

return self::$CLOUDFLARE;
}
public static function DAILYMOTION(): OAuthProvider
{
self::$DAILYMOTION ??= new OAuthProvider('dailymotion');
Expand Down Expand Up @@ -255,6 +263,12 @@ public static function PODIO(): OAuthProvider

return self::$PODIO;
}
public static function RESEND(): OAuthProvider
{
self::$RESEND ??= new OAuthProvider('resend');

return self::$RESEND;
}
public static function SALESFORCE(): OAuthProvider
{
self::$SALESFORCE ??= new OAuthProvider('salesforce');
Expand Down Expand Up @@ -352,6 +366,7 @@ public static function from(string $value): self
'bitbucket' => self::BITBUCKET(),
'bitly' => self::BITLY(),
'box' => self::BOX(),
'cloudflare' => self::CLOUDFLARE(),
'dailymotion' => self::DAILYMOTION(),
'discord' => self::DISCORD(),
'disqus' => self::DISQUS(),
Expand All @@ -374,6 +389,7 @@ public static function from(string $value): self
'paypal' => self::PAYPAL(),
'paypalSandbox' => self::PAYPALSANDBOX(),
'podio' => self::PODIO(),
'resend' => self::RESEND(),
'salesforce' => self::SALESFORCE(),
'slack' => self::SLACK(),
'spotify' => self::SPOTIFY(),
Expand Down
Loading
Loading