PHPackages                             mesahub/client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. mesahub/client

ActiveLibrary[Database &amp; ORM](/categories/database)

mesahub/client
==============

PHP SDK for mesahub — access SQLite databases from PHP

v1.0.1(1mo ago)012MITPHPPHP &gt;=8.1CI passing

Since May 8Pushed 2w agoCompare

[ Source](https://github.com/mesahub-db/mesahub-pkg-php)[ Packagist](https://packagist.org/packages/mesahub/client)[ RSS](/packages/mesahub-client/feed)WikiDiscussions trunk Synced 1w ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

MesaHub PHP SDK
===============

[](#mesahub-php-sdk)

PHP SDK for [MesaHub](https://mesahub.app) — access SQLite databases from PHP with raw SQL or a high-level table API.

Requirements
------------

[](#requirements)

- PHP 8.1+
- [Guzzle 7](https://docs.guzzlephp.org/)

Installation
------------

[](#installation)

Add the VCS repository to your `composer.json`:

```
{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/mesahub-db/mesahub-pkg-php.git"
        }
    ],
    "require": {
        "mesahub/client": "^0.1.0"
    }
}
```

Then run:

```
composer install
```

Quick Start
-----------

[](#quick-start)

```
use Mesahub\MesahubClient;

$client = new MesahubClient(
    apiKey: 'shs_your_api_key',        // from mesahub.app → Settings → API Keys
    apiUrl: 'https://api.mesahub.app', // or your dedicated / self-hosted instance URL
);

$db    = $client->db('my-app-db');    // your database slug from the dashboard
$users = $db->table('users');

// High-level table API
$all    = $users->find(where: ['active' => 1], limit: 20);
$alice  = $users->findOne(where: ['email' => 'alice@example.com']);
$count  = $users->count(where: ['active' => 1]);
$newRow = $users->insert(['name' => 'Bob', 'email' => 'bob@example.com', 'active' => 1]);

$users->update(where: ['id' => $newRow['id']], set: ['name' => 'Robert']);
$users->delete(where: ['id' => $newRow['id']]);

// Raw SQL
$result = $db->query('SELECT * FROM users WHERE active = ?', [1]);
print_r($result->rows);

$db->exec('CREATE TABLE IF NOT EXISTS logs (msg TEXT, created_at TEXT)');
```

Connection String
-----------------

[](#connection-string)

```
$info   = MesahubClient::parseMesahubUrl('mh://shs_abc@mycore.railway.app/mydb');
$client = new MesahubClient(
    apiKey:      $info['api_key'],
    apiUrl:      $info['api_url'],
    routePrefix: $info['route_prefix'],
);
$db = $client->db($info['db_name']);
```

Format: `mh://apikey@host[:port]/dbname`

- Remote hosts (e.g. `railway.app`) → HTTPS, `/v1/` routes
- `localhost` / Docker service names / `*.internal` → HTTP, `/api/` routes

WHERE Filters
-------------

[](#where-filters)

```
// Shorthand equality
$users->find(where: ['active' => 1]);

// Comparison operators
$users->find(where: ['age' => ['gte' => 18], 'score' => ['lt' => 100]]);

// LIKE
$users->find(where: ['name' => ['like' => '%alice%']]);

// IN / NOT IN
$users->find(where: ['role' => ['in' => ['admin', 'editor']]]);

// NULL checks
$users->find(where: ['deleted_at' => ['is_null' => true]]);
$users->find(where: ['verified_at' => ['is_not_null' => true]]);
```

All conditions in a single `where` array are combined with `AND`.

Operator keySQL equivalent*(plain value)*`= ?``eq``= ?``ne``!= ?``gt``> ?``gte``>= ?``lt``< ?``lte``find(
    where:   ['active' => 1],
    select:  ['id', 'name', 'email'],
    orderBy: [['column' => 'created_at', 'direction' => 'desc']],
    limit:   10,
    offset:  20,
);
```

`insertMany()`
--------------

[](#insertmany)

```
$db->table('logs')->insertMany(
    rows:       [['msg' => 'started'], ['msg' => 'done']],
    onConflict: 'ignore', // 'ignore' | 'replace' | ''
);
```

Files
-----

[](#files)

```
$files = $db->files;

// List
$listing = $files->list(limit: 10, folderPrefix: 'reports/');

// Upload
$record = $files->upload(file_get_contents('report.pdf'), 'report.pdf', 'application/pdf');
echo $record->url;

// Download
$data = $files->download($record->id);

// Delete
$files->delete($record->id);
```

Error Handling
--------------

[](#error-handling)

```
use Mesahub\Errors\MesahubException;
use Mesahub\Errors\AuthenticationException;
use Mesahub\Errors\NotFoundException;

try {
    $db->query('SELECT * FROM users');
} catch (AuthenticationException $e) {
    echo 'Invalid API key';
} catch (MesahubException $e) {
    echo "[{$e->errorCode}] {$e->statusCode}: {$e->getMessage()}";
}
```

Result Types
------------

[](#result-types)

TypeProperties`QueryResult``rows`, `columns`, `rowCount`, `queryDurationMs``ExecResult``rowsAffected`, `lastInsertRowid`, `queryDurationMs``FileRecord``id`, `filename`, `folderPath`, `sizeBytes`, `contentType`, `url`, `uploadedAt`, `expiresAt`, `metadata`Self-Hosting
------------

[](#self-hosting)

```
$client = new MesahubClient(
    apiKey:      'your-admin-token',
    apiUrl:      'http://localhost:4004',
    routePrefix: 'api',
);
```

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance95

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

2

Last Release

30d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a4ee0f70f1fb2086bb67ef8988df4867187afa2588c5be26fd73641bec8911a2?d=identicon)[0xdps](/maintainers/0xdps)

---

Top Contributors

[![0xdps](https://avatars.githubusercontent.com/u/5993833?v=4)](https://github.com/0xdps "0xdps (9 commits)")

---

Tags

sdkdatabasesqlitemesahub

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mesahub-client/health.svg)

```
[![Health](https://phpackages.com/badges/mesahub-client/health.svg)](https://phpackages.com/packages/mesahub-client)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k532.1M2.5k](/packages/aws-aws-sdk-php)[kreait/firebase-php

Firebase Admin SDK

2.5k42.7M83](/packages/kreait-firebase-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

232.5k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
