1. Go to this page and download the library: Download campoint/postgrest-php 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/ */
campoint / postgrest-php example snippets
$clientAuthConfig = new ClientAuthConfig(
authArguments: [
'email' => '[email protected]',
'pass' => 'password',
],
);
$client = new PostgrestSyncClient(
'http://localhost:8080',
5,
clientAuthConfig: $clientAuthConfig
);
try {
$client->auth();
} catch (FailedAuthException $e) {
// do something
}
Async
^^^^^
Create a client for asynchronous environments:
.. code:: php
$clientAuthConfig = new ClientAuthConfig(
authArguments: [
'email' => '[email protected]',
'pass' => 'password',
],
);
$client = new PostgrestAsyncClient(
'http://localhost:8080',
5,
(new Browser(null, $loop)),
$clientAuthConfig
);
$client->auth()->then(
function () {
// do something on success
},
function (FailedAuthException $e) {
// do something on rejection
}
)