Code Monkey home page Code Monkey logo

sdk-for-php's Introduction

Appwrite PHP SDK

License Version Build Status Twitter Account Discord

This SDK is compatible with Appwrite server version 1.4.x. For older versions, please check previous releases.

Appwrite is an open-source backend as a service server that abstract and simplify 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

Appwrite

Installation

To install via Composer:

composer require appwrite/appwrite

Getting Started

Init your SDK

Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key from project's API keys section.

$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
;

Make Your First Request

Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.

$users = new Users($client);

$user = $users->create(ID::unique(), '[email protected]', 'password');

Full Example

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]', 'password');

Error Handling

The Appwrite PHP SDK raises AppwriteException object with message, code and response properties. You can handle any errors by catching AppwriteException and present the message to the user or handle it yourself based on the provided error information. Below is an example.

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

Learn more

You can use the following resources to learn more and get help

Contribution

This library is auto-generated by Appwrite custom SDK Generator. To learn more about how you can help us improve this SDK, please check the contribution guide before sending a pull-request.

License

Please see the BSD-3-Clause license file for more information.

sdk-for-php's People

Contributors

abnegate avatar christyjacob4 avatar eldadfux avatar lohanidamodar avatar meldiron avatar softcreatr avatar torstendittmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdk-for-php's Issues

Upgrade our issue templates to use GitHub issue forms โœ๏ธ

Introduction

GitHub has recently rolled out a public beta for their issue forms feature. This would allow you to create interactive issue templates and validate them ๐Ÿคฏ.

Appwrite currently uses the older issue template format. Your task is to create GitHub issue forms for this repository. Please use Appwrite's issue templates as a reference for this PR.

Tasks summary:

  • Fork & clone this repository
  • Prepare bug report issue form in .github/ISSUE_TEMPLATE/bug.yaml
  • Prepare documentation issue form in .github/ISSUE_TEMPLATE/documentation.yaml
  • Prepare feature request issue form in .github/ISSUE_TEMPLATE/feature.yaml
  • Push changes to master and test issue forms on your fork
  • Submit pull request

If you need any help, reach out to us on our Discord server.

Are you ready to work on this issue? ๐Ÿค” Let us know, and we will assign it to you ๐Ÿ˜Š

Happy Appwriting!

๐Ÿ“š Documentation: Query

๐Ÿ’ญ Description

Hi,

I installed AppWrite with Composer and updated it to v 3.0.0. How do I use Database queries? "use Appwrite\Query" does not work.

Thanks

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report:

๐Ÿ‘Ÿ Reproduction steps

I try to delete a file:

$storage->deleteFile($file_id);

๐Ÿ‘ Expected behavior

It should delete a file without an exception.

๐Ÿ‘Ž Actual Behavior

It actually deletes the file. But I get an uncatchable eception (even with Appwrite\AppwriteException):

Uncaught TypeError: Return value of Appwrite\Services\Storage::deleteFile() must be of the type array, string returned in /var/www/djemgo/public_html/vendor/appwrite/appwrite/src/Appwrite/Services/Storage.php:194

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

Linux

๐Ÿงฑ Your Environment

0.12.1

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: query with boolean attribute error

๐Ÿ‘Ÿ Reproduction steps

Using Appwrite 0.13.x, when I try to query my db using the code below...

$query = [ $q->equal("active",true), ];

๐Ÿ‘ Expected behavior

It should work

๐Ÿ‘Ž Actual Behavior

Instead, I get the following error:

Uncaught Appwrite\AppwriteException: Query not valid: Query type does not match expected: boolean in /var/www/test/public_html/vendor/appwrite/appwrite/src/Appwrite/Client.php:232 Stack trace: #0 /var/www/test/public_html/vendor/appwrite/appwrite/src/Appwrite/Services/Database.php(811): Appwrite\Client->call() #1

๐ŸŽฒ Appwrite version

Version 0.10.x

๐Ÿ’ป Operating system

Linux

๐Ÿงฑ Your Environment

No response

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ“š Documentation: Phone verification race condition

๐Ÿ’ญ Description

I installed appwrite to be able to authenticate users faster using SMS and Twilio as a backend.

I'm having a hard time doing server side verification because I want the user to enter their phone number in JS (frontend) and verify it using PHP but this seems to be impossible because the documentation for the Phone verification requires already a JWT which can only be issued when authentication is already finished.

In JS I have to call createPhoneSession and then run updatePhoneSession to verify the code and only when this was successful I can issue a JWT using account.createJWT()

In PHP this code fails

$client = new Client();

$client
    ->setEndpoint('https://myurl/v1')
    ->setProject('652d4af1633afc99def')
    ->setKey('528958d6e5f[..]e318fc67') // Your secret API key
    ->setSelfSigned()
;

$userid="652d5b5a9a699deabcce"; //would get this from an AJAX request from the frontend
$secret="243503"; //phone verification token

$account = new Account($client);
$result = $account->updatePhoneVerification($userid, $secret);
var_dump($result);

It fails with the error: (role: applications) missing scope (public) which means that using a API secret you can't confirm the users phone token. It needs setJWT instead of setKey but again the JWT can only be issued after authentication.

So why do these endpoints even exist in PHP when you can't use it for authentication in the backend? How is this meant to be used? Anonymous logins and afterwards backend checks?

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿš€ Feature:

๐Ÿ”– Feature description

Hi, can PHP be used as a Client API? Thanks

๐ŸŽค Pitch

Well, PHP should be used to allow web users to manage their account. Thanks

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ“š Documentation: update file with content

๐Ÿ’ญ Description

Hi, after reading your documentation, I could not figure out how to update a file I created earlier with new content. Please help. Thanks

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ“š Documentation:

๐Ÿ’ญ Description

this Sdk not include, Account client side functionality.
like [Create Account]
[ Create Email Session]
and other.

How can I do it, client side functionality in PHP SDK

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.