定制 supabase-php/supabase-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

supabase-php/supabase-client

最新稳定版本:v1.2.0

Composer 安装命令:

composer require supabase-php/supabase-client

包简介

Supabase client for PHP.

README 文档

README

Supabase

Packagist Downloads GitHub Release GitHub License Packagist Dependency Version

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 errors.

Warning

if you push the code to production while Row-Level Security (RLS) is disabled, it can pose a security threat to your application. To secure your app, please enable Row-Level Security. Otherwise, write an Object-Oriented PDO connection with PostgreSQL.

Env config code:

HOST=aws-o-ap-south-pool.supabase.com
PORT=6543
USERNAME=postgres.grufgrcytvrh
PASSWORD=[Your Password]
DATABASE=postgres

Install

  • Install Supabase client for our project.
  • Than we are require supabase-client by composer.
composer require supabase-php/supabase-client      # letest
# OR Downloads old version
composer require supabase-php/supabase-client:"1.0.4"

Config

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'],
  'service_role' => $_ENV['SB_SERVICE_ROLE'] # If don't want disable RLS 
];

$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

getAllData()

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);

getSingleData()

if you need a specifics data from specifics columns then you used getSingleData function.

$data = $client->getSingleData('table name', 'column name');
print_r($data);

postData()

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, 'id');
// 3rd option on_conflict

updateData()

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);

deleteData()

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);

Pagination()

$client->pages('table name');

Filtering()

$client->filter('table name', 1);

Matching()

$data = [
  'name' => 'PHP',
  'version' => '8.4'
];

$client->matchs('table name', $data);

Contributors

统计信息

  • 总下载量: 2.04k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固