Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 17.5.1

* Fix duplicate methods issue (e.g., `updateMFA` and `updateMfa`) causing build and runtime errors

## 17.5.0

* Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"url": "https://appwrite.io/support",
"email": "[email protected]"
},
"scripts": {
"test": "vendor/bin/phpunit"
},
"autoload": {
"psr-4": {
"Appwrite\\": "src/Appwrite"
Expand All @@ -19,7 +22,7 @@
},
"require-dev": {
"phpunit/phpunit": "^10",
"mockery/mockery": "^1.6.6"
"mockery/mockery": "^1.6.12"
},
"minimum-stability": "dev"
}
36 changes: 36 additions & 0 deletions docs/avatars.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,39 @@ GET https://cloud.appwrite.io/v1/avatars/qr
| margin | integer | Margin from edge. Pass an integer between 0 to 10. Defaults to 1. | 1 |
| download | boolean | Return resulting image with 'Content-Disposition: attachment ' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0. | |


```http request
GET https://cloud.appwrite.io/v1/avatars/screenshots
```

** Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image.

You can configure the browser viewport size, theme, user agent, geolocation, permissions, and more. Capture either just the viewport or the full page scroll.

When width and height are specified, the image is resized accordingly. If both dimensions are 0, the API provides an image at original size. If dimensions are not specified, the default viewport size is 1280x720px. **

### Parameters

| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| url | string | **Required** Website URL which you want to capture. | |
| headers | object | HTTP headers to send with the browser request. Defaults to empty. | {} |
| viewportWidth | integer | Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280. | 1280 |
| viewportHeight | integer | Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720. | 720 |
| scale | number | Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1. | 1 |
| theme | string | Browser theme. Pass "light" or "dark". Defaults to "light". | light |
| userAgent | string | Custom user agent string. Defaults to browser default. | |
| fullpage | boolean | Capture full page scroll. Pass 0 for viewport only, or 1 for full page. Defaults to 0. | |
| locale | string | Browser locale (e.g., "en-US", "fr-FR"). Defaults to browser default. | |
| timezone | string | IANA timezone identifier (e.g., "America/New_York", "Europe/London"). Defaults to browser default. | |
| latitude | number | Geolocation latitude. Pass a number between -90 to 90. Defaults to 0. | 0 |
| longitude | number | Geolocation longitude. Pass a number between -180 to 180. Defaults to 0. | 0 |
| accuracy | number | Geolocation accuracy in meters. Pass a number between 0 to 100000. Defaults to 0. | 0 |
| touch | boolean | Enable touch support. Pass 0 for no touch, or 1 for touch enabled. Defaults to 0. | |
| permissions | array | Browser permissions to grant. Pass an array of permission names like ["geolocation", "camera", "microphone"]. Defaults to empty. | [] |
| sleep | integer | Wait time in seconds before taking the screenshot. Pass an integer between 0 to 10. Defaults to 0. | 0 |
| width | integer | Output image width. Pass 0 to use original width, or an integer between 1 to 2000. Defaults to 0 (original width). | 0 |
| height | integer | Output image height. Pass 0 to use original height, or an integer between 1 to 2000. Defaults to 0 (original height). | 0 |
| quality | integer | Screenshot quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. | -1 |
| output | string | Output format type (jpeg, jpg, png, gif and webp). | |

34 changes: 34 additions & 0 deletions docs/examples/avatars/get-screenshot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Appwrite\Client;
use Appwrite\Services\Avatars;

$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

$avatars = new Avatars($client);

$result = $avatars->getScreenshot(
url: 'https://example.com',
headers: [], // optional
viewportWidth: 1, // optional
viewportHeight: 1, // optional
scale: 0.1, // optional
theme: ::LIGHT(), // optional
userAgent: '<USER_AGENT>', // optional
fullpage: false, // optional
locale: '<LOCALE>', // optional
timezone: ::AFRICAABIDJAN(), // optional
latitude: -90, // optional
longitude: -180, // optional
accuracy: 0, // optional
touch: false, // optional
permissions: [], // optional
sleep: 0, // optional
width: 0, // optional
height: 0, // optional
quality: -1, // optional
output: ::JPG() // optional
);
2 changes: 1 addition & 1 deletion docs/sites.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ GET https://cloud.appwrite.io/v1/sites/{siteId}/deployments
POST https://cloud.appwrite.io/v1/sites/{siteId}/deployments
```

** Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you&#039;ll need to update the function&#039;s deployment to use your new deployment ID. **
** Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you&#039;ll need to update the site&#039;s deployment to use your new deployment ID. **

### Parameters

Expand Down
32 changes: 32 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
colors="true"
displayDetailsOnIncompleteTests="true"
displayDetailsOnSkippedTests="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
failOnDeprecation="true"
failOnEmptyTestSuite="true"
failOnIncomplete="true"
failOnRisky="true"
failOnSkipped="true"
failOnWarning="true"
>
<testsuites>
<testsuite name="Appwrite SDK Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>

<source>
<include>
<directory suffix=".php">./src/Appwrite</directory>
</include>
</source>
</phpunit>
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/17.5.0 ()',
'user-agent' => 'AppwritePHPSDK/17.5.1 ()',
'x-sdk-name'=> 'PHP',
'x-sdk-platform'=> 'server',
'x-sdk-language'=> 'php',
'x-sdk-version'=> '17.5.0',
'x-sdk-version'=> '17.5.1',
];

/**
Expand Down
83 changes: 83 additions & 0 deletions src/Appwrite/Enums/Output.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

namespace Appwrite\Enums;

use JsonSerializable;

class Output implements JsonSerializable
{
private static Output $JPG;
private static Output $JPEG;
private static Output $PNG;
private static Output $WEBP;
private static Output $HEIC;
private static Output $AVIF;
private static Output $GIF;

private string $value;

private function __construct(string $value)
{
$this->value = $value;
}

public function __toString(): string
{
return $this->value;
}

public function jsonSerialize(): string
{
return $this->value;
}

public static function JPG(): Output
{
if (!isset(self::$JPG)) {
self::$JPG = new Output('jpg');
}
return self::$JPG;
}
public static function JPEG(): Output
{
if (!isset(self::$JPEG)) {
self::$JPEG = new Output('jpeg');
}
return self::$JPEG;
}
public static function PNG(): Output
{
if (!isset(self::$PNG)) {
self::$PNG = new Output('png');
}
return self::$PNG;
}
public static function WEBP(): Output
{
if (!isset(self::$WEBP)) {
self::$WEBP = new Output('webp');
}
return self::$WEBP;
}
public static function HEIC(): Output
{
if (!isset(self::$HEIC)) {
self::$HEIC = new Output('heic');
}
return self::$HEIC;
}
public static function AVIF(): Output
{
if (!isset(self::$AVIF)) {
self::$AVIF = new Output('avif');
}
return self::$AVIF;
}
public static function GIF(): Output
{
if (!isset(self::$GIF)) {
self::$GIF = new Output('gif');
}
return self::$GIF;
}
}
43 changes: 43 additions & 0 deletions src/Appwrite/Enums/Theme.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Appwrite\Enums;

use JsonSerializable;

class Theme implements JsonSerializable
{
private static Theme $LIGHT;
private static Theme $DARK;

private string $value;

private function __construct(string $value)
{
$this->value = $value;
}

public function __toString(): string
{
return $this->value;
}

public function jsonSerialize(): string
{
return $this->value;
}

public static function LIGHT(): Theme
{
if (!isset(self::$LIGHT)) {
self::$LIGHT = new Theme('light');
}
return self::$LIGHT;
}
public static function DARK(): Theme
{
if (!isset(self::$DARK)) {
self::$DARK = new Theme('dark');
}
return self::$DARK;
}
}
Loading