Download the PHP package mameyugo/jsonq without Composer
On this page you can find all versions of the php package mameyugo/jsonq. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mameyugo/jsonq
More information about mameyugo/jsonq
Files in mameyugo/jsonq
Package jsonq
Short Description High-performance JSON file storage engine for PHP, powered by Rust
License PHP-3.01
Homepage https://github.com/mameyugo/JsonQ
Informations about the package jsonq
π What is JsonQ?
JsonQ is a blazing-fast PHP extension written in Rust that provides a file-based JSON storage engine with MongoDB-style queries, schema validation, indexing, and transactions.
Why JsonQ?
- π 2-10x faster than pure PHP JSON handling
- πΎ File-based - No server required, zero configuration
- π MongoDB-style queries - Familiar syntax with 17+ operators
- β Schema validation - JSON Schema subset support
- π ACID transactions - Atomic operations with rollback
- π Indexing - Hash-based O(1) lookups
- π‘οΈ Thread-safe - OS-level file locking with fs2
- β‘ SIMD-accelerated - Fast parsing with simd-json
β¨ Features
Core Storage
- β CRUD Operations with dot-notation path access
- β Atomic Writes (tmp + fsync + rename) for crash safety
- β Memory-mapped I/O for zero-copy reads
- β Arc-based Caching with mtime invalidation
- β Compression Support (Gzip, Zstd) - v0.3.2
- β Native Streaming (v0.4.0) - Iterate gigabytes of data with low memory
- β Stream Filtering - Apply MongoDB-style queries while streaming
Query Engine
- β
MongoDB-style Matching:
$eq,$ne,$gt,$gte,$lt,$lte,$in,$nin - β
String Operators:
$contains,$startsWith,$endsWith,$regex - β
Logical Operators:
$and,$or,$not,$nor - β
Array Operators:
$size,$all,$elemMatch - β
Type Checking:
$exists,$type - β
Field Projection:
select()for whitelisting fields - v0.3.2 - β Query Optimizer: Intelligent index selection - v0.3.2
Fluent Query Builder
- β
Chainable Methods:
where(),orWhere(),orderBy(),limit(),skip() - β Filtering: Comparison, string, array operators
- β Sorting: Ascending/descending on any field
- β
Pagination:
skip+limitsupport
Aggregation & Analysis
- β
Functions:
sum(),avg(),min(),max(),count() - β
Grouping:
groupBy()with field-based grouping - β
Field Extraction:
pluck()for column extraction
Validation & Schema
- β JSON Schema Validation (subset)
- β Type Constraints: string, number, boolean, array, object
- β String Formats: email, URL, IPv4, date, UUID
- β Number Constraints: min, max, multipleOf
- β Array Constraints: minItems, maxItems, uniqueItems
- β Required Fields and enum validation
- β Conditional Logic: if/then/else, oneOf, anyOf
Indexing
- β Single Field Indexes: O(1) equality lookups
- β Compound Indexes: Multi-field indexing
- β Hash-based: MD5 hashing for fast lookups
- β
Auto-optimization: Automatic use in
find()queries
Transactions
- β ACID Guarantees: Atomic, Consistent, Isolated, Durable
- β Begin/Commit/Rollback: Full transaction support
- β Isolation: Transaction-local changes until commit
Advanced Features (v0.3.0)
- β Safe Regex - ReDoS protection with backtracking limits
- β Metrics API - Real-time observability (reads, writes, cache stats, latency)
- β Compression - Transparent Gzip/Zstd support
- β Query Optimizer - Intelligent index selection for complex queries
Collection Methods (v0.3.2)
- β
select(fields)- Project specific fields (whitelist) - β
except(fields)- Exclude specific fields (blacklist) - β
column(field)- Extract values from single column - β
chunk(size)- Split results into groups - β
implode(field, separator)- Join column values into string - β
keys(path)- Get object keys - β
values(path)- Get object values - β
toJson(pretty)- Serialize results to JSON string
Object Hydration (NEW - v0.5.0)
- β Automatic Mapping - Map JSON arrays directly into typed PHP 8.1+ objects
- β
Typed Arrays - Support for hydrating
array<ClassName>via#[Type]attribute - β
HydratableStore - Native extension wrapper with
findOneAs,findInAs,streamAs - β
Type Coercion - Configurable
STRICTandLENIENTcoercion modes - β Round-trip Dehydration - Convert PHP objects back into JSON natively
- π Learn more about Object Hydration
Legend: β Confirmed | β³ Pending verification
π Quick Start
Installation
Via APT (Debian/Ubuntu)
Via Curl (Quick Install)
Build from Source
Hello World
π API Reference
Basic Operations
CRUD
Array Operations
MongoDB-style Queries
Comparison Operators
Array Operators
String Operators
Logical Operators
Fluent Query Builder
Available Operators:
- Comparison:
=,!=,>,>=,<,<= - Array:
in,not in - String:
contains,startsWith,endsWith - Range:
between(expects array[min, max])
Aggregation
Collection Methods (NEW)
Native Streaming (NEW - v0.4.0)
Process large JSON structures without loading everything into memory.
Schema Validation
Supported Constraints:
- Types: string, number, integer, boolean, array, object, null
- String: minLength, maxLength, pattern, format (email, url, ipv4, date, uuid)
- Number: minimum, maximum, multipleOf
- Array: minItems, maxItems, uniqueItems, items
- Object: required, properties, additionalProperties
- Enum: Fixed set of allowed values
- Conditional: if/then/else, oneOf, anyOf
Indexing
Performance Impact:
- Indexed
find()queries: ~10x faster - Index memory overhead: ~2-5% of data size
- Write penalty: <5% slower (hash computation)
Transactions
Guarantees:
- Atomicity: All changes commit together or none
- Consistency: Schema validation enforced
- Isolation: Changes invisible until commit
- Durability: fsync ensures disk persistence
Advanced Features (v0.3.0)
Compression
| Compression Comparison: | Method | Ratio | Speed | Best For |
|---|---|---|---|---|
| none | 1.0x | Fastest | Small files, frequent writes | |
| gzip | 2-3x | Fast | Good balance | |
| zstd | 2.5-4x | Fastest | Large files, best compression |
Metrics & Observability
Tracked Metrics:
- Read/write counters
- Cache hit/miss ratio
- Average read latency
- Last operation timestamp
Backup & Restore
Global Configuration
ποΈ Performance
Benchmarks (vs Pure PHP)
| Operation | JsonQ | Pure PHP | Speedup |
|---|---|---|---|
| Parse JSON | 0.8ms | 5.2ms | 6.5x faster |
| Find (no index) | 1.2ms | 12.5ms | 10.4x faster |
| Find (indexed) | 0.1ms | 12.5ms | 125x faster |
| Aggregate (sum) | 0.9ms | 8.7ms | 9.7x faster |
| Complex query | 2.1ms | 18.3ms | 8.7x faster |
| Write + fsync | 1.5ms | 3.2ms | 2.1x faster |
Benchmark environment: PHP 8.3, 10K documents, Intel i7-12700K
Optimization Tips
- Use Indexes: 10-100x speedup for equality lookups
- Enable Compression: 50-75% disk space reduction
- Batch Writes: Use transactions for multiple operations
- Monitor Metrics: Track cache hit rate and optimize queries
- Project Fields: Use
selectto return only needed data
ποΈ Architecture
π€ Contributing
Contributions are welcome! Please read CONTRIBUTING.md for guidelines.
Development Setup
Project Structure
π License
JsonQ is licensed under The PHP License, version 3.01.
π Acknowledgments
- simd-json - SIMD-accelerated JSON parsing
- ext-php-rs - Safe Rust-PHP FFI bindings
- serde - Serialization framework
- MongoDB - Query syntax inspiration
- The Rust and PHP communities
π Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: [email protected]
πΊοΈ Roadmap
v0.6.0 (Q3 2026)
- [ ] JOIN operations across collections
- [ ] Full-text search with stemming
- [ ] JSONPath full support & advanced query optimizer improvements
- [ ] Watch API for change streams
v1.0.0 (Q4 2026)
- [ ] Production-ready stable API
- [ ] >98% test coverage
- [ ] Comprehensive documentation
- [ ] Performance parity with MongoDB for complex aggregate queries
- [ ] Multi-stage aggregation pipelines
- [ ] GraphQL-like query DSL