Skip to content

juanbenitez/supabase-api

Repository files navigation

A minimal PHP implementation of the Supabase API (WIP)

Latest Version on Packagist Tests Total Downloads

This is a minimal PHP implementation of the Supabase API wich is supported by PostgREST. It contains only the methods I needed. However, I'm open to PRs that add extra methods to the client.

Supabase-api is built with help of the awesome Saloon package.

Be aware that is a work in progress, it's in pre-alpha state, use it at your own risk.

Here are a few examples on how you can use the package:

Installation

You can install the package via composer:

composer require juanbenitez/supabase-api

Usage

Define a request class for a table in your DB.

use Juanbenitez\SupabaseApi\Request\ReadRowsRequest;

class UsersReadRowsRequest extends ReadRowsRequest
{
    protected ?string $table = 'users';
}
$connector    = new SupabaseConnector('https://testbaseurl.supabase.co/rest/v1/', 'TEST_SUPABASE_SERVICE_KEY');
$usersRequest = $connector->request(new UsersReadRowsRequest());

$usersRequest->select(['last_name', 'first_name', 'age'])
            ->where('age', '18')
            ->orderBy('created_at', 'desc')
            ->limit(5);

$response = $usersRequest->send();
$response->throw();

echo "status:". $response->status() . PHP_EOL;
print_r ($response->json());

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Minimal PHP implementation of the Supabase REST API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Languages