Skip to content

php-querylang brings SQL-like syntax to PHP arrays. Write queries like SELECT * FROM $users WHERE age > 18 and run them natively without a database. Lightweight, dependency-free, and easy to extend—perfect for filtering, searching, and transforming arrays with familiar SQL-inspired expressions.

License

Notifications You must be signed in to change notification settings

makalin/php-querylang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-querylang

License PHP

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.


Features

  • ✅ SQL-inspired query syntax
  • ✅ Compile queries directly to PHP array operations
  • ✅ No database required – works with arrays/lists
  • ✅ Lightweight, zero dependencies
  • ✅ Extendable parser & compiler

Example

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],
]

Installation

composer require makalin/php-querylang

Supported Syntax

  • SELECT * FROM $array
  • WHERE with =, !=, <, >, <=, >=
  • AND, OR conditions
  • LIMIT n
  • (More operators coming soon)

Roadmap

  • Add ORDER BY
  • Add JOIN (nested arrays)
  • Add INSERT / UPDATE support

License

MIT © 2025 Mehmet T. AKALIN

About

php-querylang brings SQL-like syntax to PHP arrays. Write queries like SELECT * FROM $users WHERE age > 18 and run them natively without a database. Lightweight, dependency-free, and easy to extend—perfect for filtering, searching, and transforming arrays with familiar SQL-inspired expressions.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages