kvf77/manticore-query-builder
Composer 安装命令:
composer require kvf77/manticore-query-builder
包简介
A modern PHP query builder for Manticore Search (and Sphinx) speaking the SphinxQL dialect. A maintained fork of foolz/sphinxql-query-builder.
关键字:
README 文档
README
A modern PHP query builder for Manticore Search (and Sphinx) speaking the SphinxQL dialect over the MySQL protocol.
This is a maintained, modernised fork of
foolz/sphinxql-query-builder,
rebuilt for PHP 8.3+ with a cleaner WHERE compiler, OR/nested groups,
REGEX() support and first-class Laravel integration.
- Requires PHP 8.3+
- Drivers: PDO (default) or MySQLi
- No framework dependency in the core; optional Laravel bridge included
- Licensed under Apache-2.0 (see
LICENSEandNOTICE)
Documentation
Full docs live in docs/:
- Getting started
- SELECT & WHERE
- Full-text MATCH
- Facets — single/multiple/computed facets,
executeBatch(), the legend/stats pattern - Geo search — distance & polygon search
- Writing data
- Reading results
- Helpers & Percolate
- Laravel integration
- Migrating from foolz/sphinxql-query-builder
Installation
composer require kvf77/manticore-query-builder
Quick start (plain PHP)
use Kvf77\Manticore\Drivers\Pdo\Connection; use Kvf77\Manticore\SphinxQL; $conn = new Connection(); $conn->setParams(['host' => '127.0.0.1', 'port' => 9306]); $result = (new SphinxQL($conn)) ->select('id', 'title') ->from('articles') ->match('title', 'manticore') ->where('published', 1) ->orderBy('id', 'desc') ->limit(20) ->execute(); foreach ($result as $row) { // ... }
WHERE: AND, OR and nested groups
$qb->select()->from('idx') ->where('a', 1) ->orWhere('b', 2) ->where(function (SphinxQL $q) { $q->where('c', 3)->orWhere('d', 4); }); // WHERE a = 1 OR b = 2 AND (c = 3 OR d = 4)
Operators: = (default), comparison operators, IN, NOT IN, BETWEEN.
$qb->where('id', 'IN', [1, 2, 3]); // id IN (1, 2, 3) $qb->where('price', 'BETWEEN', [10, 100]); // price BETWEEN 10 AND 100
REGEX (Manticore)
$qb->select()->from('idx')->regex('title', '.*foo.*'); // WHERE REGEX(title, '.*foo.*')
Insert / Replace / Update / Delete
(new SphinxQL($conn))->insert()->into('idx')->set(['id' => 1, 'name' => 'John'])->execute(); (new SphinxQL($conn))->replace()->into('idx')->set(['id' => 1, 'name' => 'John'])->execute(); (new SphinxQL($conn))->update('idx')->value('views', 5)->where('id', 1)->execute(); (new SphinxQL($conn))->delete()->from('idx')->where('id', 1)->execute();
Laravel integration
The service provider is auto-discovered. Publish the config if you want to tweak it:
php artisan vendor:publish --tag=manticore-config
Set your connection in .env:
MANTICORE_HOST=127.0.0.1 MANTICORE_PORT=9306 # MANTICORE_DRIVER=pdo # or mysqli
Use the facade:
use Kvf77\Manticore\Laravel\Facades\Manticore; Manticore::insert('articles', ['id' => 1, 'title' => 'Hello']); Manticore::replace('articles', ['id' => 1, 'title' => 'Hello again']); Manticore::delete('articles', 1); $rows = Manticore::select('id', 'title') ->from('articles') ->match('title', 'hello') ->execute();
Or resolve the manager / connection from the container:
$manticore = app(\Kvf77\Manticore\Laravel\Manticore::class); $conn = app(\Kvf77\Manticore\Drivers\ConnectionInterface::class);
Testing
composer install vendor/bin/phpunit
The test suite verifies query compilation and does not require a running Manticore/Sphinx server.
Credits & license
Originally based on foolz/sphinxql-query-builder
by foolz, licensed under Apache-2.0. This fork retains that license; see LICENSE
and NOTICE for the full text and the list of changes.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2026-06-16