teddybear06 / edgedb-php
An unofficial EdgeDB PHP client.
v0.3.1
2022-08-23 19:16 UTC
Requires
- php: >=8.0
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^9
README
Requirements
- PHP >= 8.0 (with fileinfo and mbstring)
- An EdgeDB server instance (tested with 2.0.5+f78cf34)
Quickstart
Add this package to your project:
$ composer require teddybear06/edgedb-php
This is a complete usage example (or look at https://github.com/TeddyBear06/edgedb-php/tree/main/example/index.php):
// Require Composer's autoloader require '/vendor/autoload.php'; // Use required classes use TeddyBear06\EdgeDbPhp\EdgeDbHttpClient; use TeddyBear06\EdgeDbPhp\EdgeQlQuery; // Establish a connection with the EdgeDB server instance $connection = new EdgeDbHttpClient('127.0.0.1', '10700', 'edgedb'); // Create an EdgeQL query $query = new EdgeQlQuery( 'select Author {firstname, lastname} filter .lastname = <str>$lastname;', ['lastname' => 'Doe'] ); // Execute the query $response = $connection->query($query); // If there is no error message if (is_null($response->getError())) { // If there is at least 1 result if ($response->countData() > 0) { // Loop over results foreach ($response->getData() as $data) { echo $data['firstname']; } } else { // Data set is empty echo 'No matches found...'; } } else { // Call $response->getError() to get error details // message, type or code array indexes are available echo $response->getError()['message']; }
Documentation
For a complete API documentation, please go here : https://teddybear06.github.io/edgedb-php/