edgebase / admin
EdgeBase Admin SDK — server-side admin operations.
Requires
- php: >=8.1
- edgebase/core: ^0.2.9
Requires (Dev)
- phpunit/phpunit: ^10.0
README
EdgeBase PHP Admin SDK
Trusted server-side PHP SDK for EdgeBase.
Use edgebase/admin from backend APIs, jobs, workers, and other trusted PHP runtimes that hold a Service Key. It exposes admin auth, database access, raw SQL, storage, push, analytics, functions, and native edge resources.
If you are working inside this repository, AdminEdgeBase exists as a backwards-compatible alias for AdminClient. Prefer AdminClient in new code.
EdgeBase is the open-source edge-native BaaS that runs on Edge, Docker, and Node.js.
This package is one part of the wider EdgeBase platform. For the full platform, CLI, Admin Dashboard, server runtime, docs, and all public SDKs, see the main repository: edge-base/edgebase.
Documentation Map
Use this README for a fast overview, then jump into the docs when you need depth:
- SDK Overview Install commands and the public SDK matrix
- Admin SDK Trusted-server boundaries and admin-only capabilities
- Admin SDK Reference Cross-language examples for auth, database, storage, functions, push, and analytics
- Admin User Management Create, update, delete, and manage users with a Service Key
- Database Admin SDK Table queries, filters, pagination, batch writes, and raw SQL
- Storage Uploads, downloads, metadata, and signed URLs
- Analytics Admin SDK Request metrics, event tracking, and event queries
- Push Admin SDK Push send, topic broadcast, token inspection, and logs
- Native Resources KV, D1, Vectorize, and other trusted edge-native resources
For AI Coding Assistants
This package includes an llms.txt file for AI-assisted development.
Use it when you want an agent or code assistant to:
- keep Service Keys on trusted servers
- use the actual PHP property and method names
- avoid copying JavaScript promise-based examples into PHP
- know when to use
adminAuthandstorageproperties versuspush(),functions(), andanalytics()methods
You can find it:
- in this repository: llms.txt
- in your environment after install, inside the
EdgeBase\Adminpackage directory asllms.txt
Installation
composer require edgebase/admin
Quick Start
<?php use EdgeBase\Admin\AdminClient; $admin = new AdminClient( 'https://your-project.edgebase.fun', getenv('EDGEBASE_SERVICE_KEY') ?: '' ); $users = $admin->adminAuth->listUsers(limit: 20); $postRows = $admin->sql( 'shared', null, 'SELECT id, title FROM posts WHERE status = ?', ['published'] ); $bucket = $admin->storage->bucket('avatars'); $bucket->upload('user-1.jpg', 'binary-data', contentType: 'image/jpeg'); $admin->push()->send('user-1', [ 'title' => 'Deployment finished', 'body' => 'Your content is live.', ]);
Core API
$admin->adminAuthAdmin user management client$admin->storageStorage client$admin->db(namespace, instanceId = null)Service-key database access$admin->sql(namespace, id, query, params = [])Raw SQL execution$admin->broadcast(channel, event, payload = [])Server-side database-live broadcast$admin->push()Push notifications$admin->functions()Call app functions from trusted code$admin->analytics()Query analytics and track server-side events$admin->kv(namespace),$admin->d1(database),$admin->vector(index)Native edge resources$admin->destroy()No-op cleanup hook
Database Access
$posts = $admin->db('app')->table('posts'); $rows = $posts->where('status', '==', 'published')->get();
For instance databases, pass the instance ID positionally:
$admin->db('workspace', 'ws-123'); $admin->db('user', 'user-123');
Admin Users
$created = $admin->adminAuth->createUser([ 'email' => 'admin@example.com', 'password' => 'secure-pass-123', 'displayName' => 'June', ]); $admin->adminAuth->setCustomClaims($created['id'], [ 'role' => 'moderator', ]); $users = $admin->adminAuth->listUsers(limit: 20);
Raw SQL
sql() always takes an explicit namespace and optional instance ID:
$sharedRows = $admin->sql('shared', null, 'SELECT 1 AS ok'); $workspaceRows = $admin->sql( 'workspace', 'ws-123', 'SELECT * FROM documents WHERE status = ?', ['published'] );
Push And Analytics
$admin->push()->send('user-123', [ 'title' => 'Hello', 'body' => 'From the admin SDK', ]); $overview = $admin->analytics()->overview(['range' => '7d']);
Choose The Right Package
| Package | Use it for |
|---|---|
edgebase/admin |
Trusted server-side PHP code with Service Key access |
edgebase/core |
Lower-level primitives for custom integrations |
License
MIT