bosbase/php-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

bosbase/php-sdk

最新稳定版本:v0.2.1

Composer 安装命令:

composer require bosbase/php-sdk

包简介

Official PHP SDK for BosBase APIs

README 文档

README

This directory contains a PHP client that mirrors the JavaScript SDK surface so PHP services can talk to the BosBase Go backend.

Installation

composer require bosbase/php-sdk

Quick start

<?php

require __DIR__ . '/vendor/autoload.php';

use BosBase\BosBase;

$pb = new BosBase('http://127.0.0.1:8090');

// Authenticate against an auth collection
$auth = $pb->collection('users')->authWithPassword('test@example.com', '123456');

// CRUD
$posts = $pb->collection('posts')->getList(page: 1, perPage: 10);
$created = $pb->collection('posts')->create(['title' => 'Hello']);

// Files
$url = $pb->files->getUrl($created, $created['cover']);

// Realtime (runs a blocking event loop)
$unsubscribe = $pb->collection('posts')->subscribe('*', function ($event) {
    echo "Realtime event: {$event['action']}\n";
});
$pb->realtime->run(); // call poll() instead to integrate with your own loop

// Superuser SQL execution
$pb->collection('_superusers')->authWithPassword('admin@example.com', 'password');
$result = $pb->sql->execute('SELECT id, email FROM _superusers LIMIT 1');
print_r($result);

Services

  • collection(<name>) – CRUD helpers, auth flows, OTP/OAuth2, impersonation.
  • collections – Manage collections, scaffolds, indexes, schema helpers.
  • files – File URLs and download tokens.
  • logs, crons, backups, vectors, llmDocuments, langchaingo, caches, graphql, sql, redis.
  • scripts, scriptsPermissions – Manage stored functions and execution permissions (superuser).
  • plugins(method, path, options) – Proxy HTTP/SSE/WebSocket requests to configured plugins.
  • realtime – Server-sent events subscription helper.
  • pubsub – WebSocket publish/subscribe.
  • createBatch() – Transactional multi-collection writes.

Tests

Install dependencies and run the PHPUnit suite from php-sdk/:

composer install
vendor/bin/phpunit -c phpunit.xml.dist

Hooks

beforeSend($url, $options) lets you tweak outbound requests. Return ['url' => ..., 'options' => [...]] to override.
afterSend($responseMeta, $data, $options) can adjust responses before they are returned.

Realtime and PubSub

Both realtime (SSE) and pub/sub (WebSockets) expose run() methods that block and dispatch events. Call poll() (realtime) or integrate run() in a worker process to keep subscriptions active.

Notes

  • PHP 8.1+ is required.
  • WebSocket support relies on textalk/websocket; install via Composer.
  • The SDK mirrors the JS API shape; if you see differences, let us know so we can align naming/behavior.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固