PHP code example of appwrite / appwrite

1. Go to this page and download the library: Download appwrite/appwrite library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

appwrite / appwrite example snippets


$client = new Client();

$client
    ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
    ->setProject('5df5acd0d48c2') // Your project ID
    ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ->setSelfSigned() // Use only on dev mode with a self-signed SSL cert
;

$users = new Users($client);

$user = $users->create(ID::unique(), "[email protected]", "+123456789", "password", "Walter O'Brien");

use Appwrite\Client;
use Appwrite\ID;
use Appwrite\Services\Users;

$client = new Client();

$client
    ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
    ->setProject('5df5acd0d48c2') // Your project ID
    ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ->setSelfSigned() // Use only on dev mode with a self-signed SSL cert
;

$users = new Users($client);

$user = $users->create(ID::unique(), "[email protected]", "+123456789", "password", "Walter O'Brien");

$users = new Users($client);
try {
    $user = $users->create(ID::unique(), "[email protected]", "+123456789", "password", "Walter O'Brien");
} catch(AppwriteException $error) {
    echo $error->message;
}