Download the PHP package feedple/feedple-sdk without Composer
On this page you can find all versions of the php package feedple/feedple-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package feedple-sdk
Feedple PHP SDK
The official PHP SDK for the Feedple AI platform. Connect your database to Feedple with a single class — the SDK handles authentication, schema sync, and query execution automatically.
Table of Contents
- How It Works
- Requirements
- Installation
- Quick Start
- Configuration
- Identity & Access Control
- Schema Sync
- IR Query Execution
- Connection Management
- Utilities
- Running in Production
- API Reference
- License
How It Works
- Connect & Authenticate — Establishes a secure background connection and authenticates your API key. The server responds with a
session_idused to resume sessions after disconnects. - Sync Schema — Inspects your database (tables, columns, PKs, FKs, indexes) and sends the schema to Feedple in chunks. Re-syncs on a configurable interval; skips if nothing changed.
- Execute Queries — Receives incoming IR query requests from Feedple, enforces RBAC, executes them safely as parameterized PDO statements, and returns the results.
Requirements
- PHP ≥ 8.1
- Composer
- A database accessible via PDO (MySQL, PostgreSQL, SQLite, and others)
- The
pdo_<driver>PHP extension for your database (e.g.pdo_mysql,pdo_pgsql,pdo_sqlite)
Installation
No additional configuration is needed — Composer's autoloader handles all class loading automatically.
Quick Start
Important:
run()starts the ReactPHP event loop, which blocks untilstop()is called. In a web application, call this in a dedicated CLI worker process — not inside a request handler.
Configuration
All constructor parameters except the first three are optional.
Parameter Reference
| Parameter | Type | Default | Description |
|---|---|---|---|
apiKey |
string |
required | Your Feedple API key. Throws InvalidArgumentException if empty. |
db |
PDO |
required | PDO database connection. |
identity |
Identity |
required | Controls which tables are accessible. |
autoSync |
bool |
true |
Periodically re-inspect and send the schema. |
syncInterval |
int |
60 |
Seconds between schema re-sync cycles. |
reconnectEnabled |
bool |
true |
Automatically reconnect on connection loss. |
maxRetries |
int\|null |
null |
Cap on reconnect attempts. null means unlimited. |
probeBeforeConnect |
bool |
false |
Perform a pre-connection HTTP probe to surface clearer server error messages (e.g. 403 bodies). |
logger |
LoggerInterface\|null |
null |
PSR-3 logger. A stderr logger is used when null. |
wsUrl |
string\|null |
null |
Override the default Feedple server endpoint URL. |
Identity & Access Control
Identity controls which database tables Feedple can see and query.
Identity Properties
| Property | Type | Default | Description |
|---|---|---|---|
name |
string\|null |
— | Human-readable label for this identity. |
allowedTables |
string[] |
[] |
Tables this identity may access. Ignored when allTables is true. |
allTables |
bool |
false |
When true, all current and future tables are accessible. |
Security: The SDK enforces RBAC on every IR query received from the server. If the IR references a table not in
allowedTables, aRuntimeExceptionis thrown and anir.erroris sent back to the server — the query never reaches the database.
Schema Sync
The SDK automatically syncs your schema on startup (after authentication) and then every syncInterval seconds. You can also trigger a manual sync:
What gets synced
For each table the identity can access, the SDK sends:
- Columns — name, type string, nullable flag, default value
- Primary key — constrained column names
- Foreign keys — local columns, referenced table, referenced columns
- Indexes — name, column names, unique flag
- Unique constraints — name, column names
Database support
Schema introspection uses standard INFORMATION_SCHEMA queries (MySQL, PostgreSQL) and PRAGMA statements (SQLite), with no external dependencies.
| Database | PDO driver | Support |
|---|---|---|
| MySQL / MariaDB | pdo_mysql |
✅ Full |
| PostgreSQL | pdo_pgsql |
✅ Full |
| SQLite | pdo_sqlite |
✅ Full |
| Others | Any | ⚠️ Partial (via ANSI INFORMATION_SCHEMA) |
Sensitive column filtering
The following column names are never sent to Feedple:
password, token, secret, hash, salt, ssn, credit_card
You can apply this filter manually:
IR Query Execution
The SDK receives IR (Intermediate Representation) query objects from the Feedple server and executes them as parameterized PDO statements against your database. You do not call this yourself — it is invoked automatically over the background connection.
IR Schema
Supported filter operators
| Operator | Aliases | SQL |
|---|---|---|
eq |
= |
col = ? |
neq |
!= |
col != ? |
gt |
> |
col > ? |
gte |
>= |
col >= ? |
lt |
< |
col < ? |
lte |
<= |
col <= ? |
in |
in_ |
col IN (?, ?, …) |
like |
— | col LIKE ? |
ilike |
— | col ILIKE ? |
Supported aggregate expressions
count, count(distinct), sum, avg, min, max
SQL injection safety
IrBuilder never uses string interpolation for values. All values are passed as PDO bound parameters (?). Identifiers (table and column names) are validated against [a-zA-Z0-9_$]+ before being double-quoted.
Connection Management
Reconnect behaviour
The SDK reconnects automatically using exponential back-off:
| Attempt | Delay |
|---|---|
| 1 | 5 s |
| 2 | 10 s |
| 3 | 20 s |
| 4+ | 40 s → capped at 60 s |
Authentication failures (auth.error) are not retried — the SDK stops the event loop immediately and logs the error.
Session resume
The session_id received in auth.ack is stored in $ws->sessionId and re-sent on every reconnect attempt. The server resumes the session if it is still within TTL, or issues a new session ID if it has expired.
Stopping the SDK
Closes the background connection and stops the worker event loop. Safe to call from a signal handler:
Utilities
IrBuilder — build SQL from an IR payload
SqlCompiler — validate raw SQL against RBAC
SchemaServices — schema utilities
PolicyEngine — direct RBAC checks
JsonSerializer — safe JSON encoding
Running in Production
As a standalone CLI worker
The simplest approach is a dedicated PHP process managed by your process manager:
With Supervisor
With a PSR-3 logger (Monolog)
Environment URLs
The SDK targets the development server (localhost:8000) by default. Switch to production by overriding the wsUrl parameter:
API Reference
FeedpleSDK
Identity
PolicyEngine
IrBuilder
SchemaServices
SqlCompiler
JsonSerializer
Exceptions
| Class | Extends | When thrown |
|---|---|---|
AuthException |
RuntimeException |
Connection authentication fails (auth.error received) |
SchemaSyncException |
RuntimeException |
Schema sync HTTP/API call fails |
IrExecutionException |
RuntimeException |
IR query execution error (unused directly — RuntimeException is thrown inline) |
Testing
Tests requiring a live database (SQLite, MySQL) are automatically skipped when the corresponding PDO driver is not installed. The pure-logic tests (IR builder, policy engine, schema hash/filter) always run.
License
feedple-sdk is distributed under the terms of the MIT license.
All versions of feedple-sdk with dependencies
monolog/monolog Version ^3.0
psr/log Version ^3.0
ratchet/pawl Version ^0.4
react/event-loop Version ^1.5