wowoengine/sawitdb-php 问题修复 & 功能扩展

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

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

wowoengine/sawitdb-php

Composer 安装命令:

composer require wowoengine/sawitdb-php

包简介

PHP Port of SawitDB Node.JS Version - A single-file NoSQL database for PHP.

README 文档

README

SawitDB Banner

Docs Packagist Node.js Version Go Version

SawitDB is a unique database solution stored in .sawit binary files.

The system features a custom Paged Heap File architecture similar to SQLite, using fixed-size 4KB pages to ensure efficient memory usage. What differentiates SawitDB is its unique Agricultural Query Language (AQL), which replaces standard SQL keywords with Indonesian farming terminology.

Now availability on Packagist!

🚨 Emergency: Aceh Flood Relief Please support our brothers and sisters in Aceh.

Kitabisa

Organized by Human Initiative Aceh

Features

  • Paged Architecture: Data is stored in 4096-byte binary pages.
  • Object Caching (New): Implements Page-Level Object Caching for high-speed reads (bypassing JSON parse for hot pages).
  • Hash Joins (New): Optimized JOIN operations (O(M+N)) for massive performance gains on relations.
  • Persistent Indexes (New): Indexes are now automatically persisted in _indexes system table and restored on load.
  • Query Cache (New): LRU Cache for parsed queries to reduce CPU overhead.
  • Zero Bureaucracy: Built with standard PHP. No massive vendor dependencies.
  • Network Support: Client-Server architecture using PHP Streams.

Philosophy

Filosofi (ID)

SawitDB dibangun dengan semangat "Kemandirian Data". Kami percaya database yang handal tidak butuh Infrastruktur Langit yang harganya triliunan tapi sering down. Berbeda dengan proyek negara yang mahal di budget tapi murah di kualitas, SawitDB menggunakan arsitektur Single File (.sawit) yang hemat biaya. Backup cukup copy-paste, tidak perlu sewa vendor konsultan asing. Fitur fsync kami menjamin data tertulis di disk, karena bagi kami, integritas data adalah harga mati.

Philosophy (EN)

SawitDB is built with the spirit of "Data Sovereignty". We believe a reliable database doesn't need "Sky Infrastructure" that costs trillions yet goes down often. Unlike state projects that are expensive in budget but cheap in quality, SawitDB uses a cost-effective Single File (.sawit) architecture. Backup is just copy-paste.

Installation

Install via Composer:

composer require wowoengine/sawitdb-php

Framework Support

Vanilla PHP & CodeIgniter 4

SawitDB acts as a standard PSR-4 library. You can use the WowoEngine directly or connect via the Client.

use SawitDB\Engine\WowoEngine;
$db = new WowoEngine(__DIR__ . '/plantation.sawit');

Laravel Integration

SawitDB includes a ServiceProvider and Facade for seamless Laravel integration.

  1. Install via Composer: composer require wowoengine/sawitdb-php
  2. Configuration: Publish the config or add to config/database.php.
// config/database.php
'connections' => [
    'sawit' => [
        'database' => env('SAWIT_DB_DATABASE', database_path('plantation.sawit')),
    ],
],
  1. Usage:
use SawitDB;

// In Controller
public function index() {
    SawitDB::query("LAHAN users");
    SawitDB::query("TANAM KE users (name) BIBIT ('Budi')");
    return SawitDB::query("PANEN * DARI users");
}

Quick Start (Network Edition)

1. Start the Server

php bin/sawit-server.php

The server will start on 0.0.0.0:7878 by default.

2. Connect with Client (CLI)

php cli/remote.php sawitdb://localhost:7878/my_plantation

Usage (Embedded)

You can use the WowoEngine directly in your PHP applications.

use SawitDB\Engine\WowoEngine;

$db = new WowoEngine(__DIR__ . '/plantation.sawit');

// Generic SQL
$db->query("CREATE TABLE users");
$db->query("INSERT INTO users (id, name) VALUES (1, 'Budi')");

// AQL
$db->query("LAHAN trees");
$db->query("TANAM KE trees (id, type) BIBIT (1, 'Dura')");

// Join
$rows = $db->query("SELECT * FROM trees JOIN users ON trees.id = users.id");
print_r($rows);

Architecture Details

  • Modular Codebase: Engine logic separated into src/ components.
  • Page 0 (Master Page): Contains header and Table Directory.
  • Data & Indexes: Stored in 4KB atomic pages.
  • WowoEngine: Core engine orchestrating Pager, Index, and Query Parser.

Full Feature Comparison

Feature Tani Edition (AQL) Generic SQL (Standard) Notes
Create DB BUKA WILAYAH [db] CREATE DATABASE [db] Creates .sawit in data/
Use DB MASUK WILAYAH [db] USE [db] Switch context
Show DBs LIHAT WILAYAH SHOW DATABASES Lists available DBs
Drop DB BAKAR WILAYAH [db] DROP DATABASE [db] Irreversible!
Create Table LAHAN [table] CREATE TABLE [table] Schema-less creation
Show Tables LIHAT LAHAN SHOW TABLES Lists tables in DB
Drop Table BAKAR LAHAN [table] DROP TABLE [table] Deletes table & data
Insert TANAM KE [table] ... BIBIT (...) INSERT INTO [table] (...) VALUES (...) Auto-ID if omitted
Select PANEN ... DARI [table] DIMANA ... SELECT ... FROM [table] WHERE ... Supports Projection
Join ... GABUNG [tbl] PADA ... ... JOIN [tbl] ON ... Hash/Nested Loop
Update PUPUK [table] DENGAN ... DIMANA ... UPDATE [table] SET ... WHERE ... Atomic update
Delete GUSUR DARI [table] DIMANA ... DELETE FROM [table] WHERE ... Row-level deletion
Index INDEKS [table] PADA [field] CREATE INDEX ON [table] (field) B-Tree Indexing
Count HITUNG COUNT(*) DARI [table] SELECT COUNT(*) FROM [table] (via HITUNG) Aggregation

Supported Operators Table

Operator Syntax Example Description
Comparison =, !=, >, <, >=, <= Standard value comparison
Logical AND, OR Combine multiple conditions (AND > OR)
In List IN ('coffee', 'tea') Matches any value in the list
Not In NOT IN ('water') Matches values NOT in list
Pattern LIKE 'Jwa%' Standard SQL wildcard matching
Range BETWEEN 1000 AND 5000 Inclusive range check
Null IS NULL Check if field is empty/null
Not Null IS NOT NULL Check if field has value
Limit LIMIT 10 Restrict number of rows
Offset OFFSET 5 Skip first N rows (Pagination)
Order ORDER BY price DESC Sort by field (ASC/DESC)

License

MIT License

wowoengine/sawitdb-php 适用场景与选型建议

wowoengine/sawitdb-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 44 次下载、GitHub Stars 达 20, 最近一次更新时间为 2026 年 01 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「nosql」 「database」 「php」 「embedded」 「flatfile」 「sawitdb」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 wowoengine/sawitdb-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 wowoengine/sawitdb-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 wowoengine/sawitdb-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-05