Supabase client for PHP:
- Realtime database, Storage, Authentication and many more.
- When you creating your supabase table, make sure RLS (Row Level Security) option be [×] disable.
- If RLS are enable [✓] maybe you getting some error so you need to use
Auth class
. Auth class coming soon.
- Install Supabase client for our project.
- Than we are require supabase-client by composer.
composer require supabase-php/supabase-client:"1.0.4"
Supabase client for PHP configuration with your php project/web Apps.
use Supabase\Functions as Supabase;
// autoload the supabase class
require_once('vendor/autoload.php');
// config
$config = [
'url' => $_ENV['SB_URL'],
'apikey' => $_ENV['SB_APIKEY']
];
$client = new Supabase($config['url'], $config['apikey']);
if you did not have .env
file so please create your .env
file.
touch .env
if you create already your .env
file then you will be derclare your enviroment variables names.
vi .env
SB_URL=https://rurtighghurtuhouger.supabase.co
SB_API_KEY=utertu895tyut8trrvt8rtu8mutt84r548t894v98v5vtt6ut54uu85tu
if you want to get all recorded data from your table when you saved the data then used getAllData
function.
$data = $client->getAllData('table name');
print_r($data);
if you need a specifics data from specifics columns then you used getSingleData
function.
$data = $client->getSingleData('table name', 'column name');
print_r($data);
if you want to save your data to your table then used postData
function.
// posted data
$data = [
'name' => 'PHP',
'version' => '8.3'
];
$client->postData('table name', $data);
if you thinks something to be wrong or outdated so you will be changing that particular value from particular columns and also you updating all the data.
Then used updateData
function.
// updated data
$data = [
'name' => 'PHP',
'version' => '8.4'
];
$client->updateData('table name', 'id number', $data);
if you want to Delete a specificed data from the table, then used deleteData
function.
you needed the id number of table data.
$client->deleteData('table name', 2 //id);
$client->pages('table name');
$client->filter('table name', 1);
$data = [
'name' => 'PHP',
'version' => '8.4'
];
$client->matchs('table name', $data);
- Auth Class coming soon.
- storage class coming soon.