SQL-like syntax compiled to native PHP arrays.
Write queries in a familiar style (SELECT * FROM $users WHERE age > 18) and run them natively against arrays without a database engine.
- ✅ SQL-inspired query syntax
- ✅ Compile queries directly to PHP array operations
- ✅ No database required – works with arrays/lists
- ✅ Lightweight, zero dependencies
- ✅ Extendable parser & compiler
use QueryLang\Query;
$users = [
['id' => 1, 'name' => 'Alice', 'age' => 17],
['id' => 2, 'name' => 'Bob', 'age' => 22],
['id' => 3, 'name' => 'Carol', 'age' => 30],
];
$query = "SELECT * FROM \$users WHERE age > 18";
$result = Query::run($query, compact('users'));
print_r($result);Output:
[
['id' => 2, 'name' => 'Bob', 'age' => 22],
['id' => 3, 'name' => 'Carol', 'age' => 30],
]composer require makalin/php-querylangSELECT * FROM $arrayWHEREwith=,!=,<,>,<=,>=AND,ORconditionsLIMIT n- (More operators coming soon)
- Add
ORDER BY - Add
JOIN(nested arrays) - Add
INSERT/UPDATEsupport
MIT © 2025 Mehmet T. AKALIN