https://github.com/juanbenitez/supabase-api
Minimal PHP implementation of the Supabase REST API
https://github.com/juanbenitez/supabase-api
api php postgresql postgrest supabase
Last synced: about 1 year ago
JSON representation
Minimal PHP implementation of the Supabase REST API
- Host: GitHub
- URL: https://github.com/juanbenitez/supabase-api
- Owner: juanbenitez
- License: mit
- Created: 2022-08-29T09:06:40.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-10-09T12:34:23.000Z (over 2 years ago)
- Last Synced: 2024-11-14T13:11:40.242Z (over 1 year ago)
- Topics: api, php, postgresql, postgrest, supabase
- Language: PHP
- Homepage:
- Size: 51.8 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# A minimal PHP implementation of the Supabase API (WIP)
[](https://packagist.org/packages/juanbenitez/supabase-api)
[](https://github.com/juanbenitez/supabase-api/actions/workflows/run-tests.yml)
[](https://packagist.org/packages/juanbenitez/supabase-api)
This is a minimal PHP implementation of the [Supabase API](https://supabase.com/docs/guides/api) wich is supported by [PostgREST](https://postgrest.org/en/stable/index.html). 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](https://docs.saloon.dev/) 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:
```bash
composer require juanbenitez/supabase-api
```
## Usage
Define a request class for a table in your DB.
```php
use Juanbenitez\SupabaseApi\Request\ReadRowsRequest;
class UsersReadRowsRequest extends ReadRowsRequest
{
protected ?string $table = 'users';
}
```
```php
$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
```bash
composer test
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Juan Benitez](https://github.com/juanbenitez)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.