foolz/sphinxql-query-builder
MATCH(), FACET, KNN) into a fluent interface, reducing boilerplate for search-heavy applications.mysqli and PDO drivers, enabling flexibility in Laravel’s database layer (e.g., shared infrastructure with MySQL while leveraging Sphinx/Manticore for search).where(), join(), orderBy()), easing adoption for teams familiar with Eloquent. Specialized methods (e.g., match(), facet(), percolate()) extend functionality beyond traditional SQL.SHOW TABLES), critical for performance in high-throughput systems.Foolz\SphinxQL\SphinxQL and Foolz\SphinxQL\Helper to the container with configurable connection names (e.g., sphinx, manticore).$this->app->bind('sphinx', function ($app) {
return new SphinxQL(new Connection([
'host' => config('search.connections.sphinx.host'),
'port' => config('search.connections.sphinx.port'),
]));
});
Search facade to provide a Laravel-idiomatic interface:
Search::query()->from('articles')->match('title', 'laravel')->get();
search() scope or trait:
public function scopeSearch($query, $term) {
return $query->from('articles')->match('title', $term);
}
QueryBuilder::macro('sphinxMatch', function ($field, $term) {
return (new SphinxQL($this->getConnection()->getPdo()))
->from($this->from)
->match($field, $term);
});
Illuminate\Database uses PDO by default, while this package supports both PDO and mysqli. Mixed driver usage could lead to inconsistencies in connection handling.ResultSetInterface differs from Laravel’s Illuminate\Database\ResultSet. Custom adapters may be needed to integrate with Laravel’s query result processing (e.g., pagination, collections).foolz/sphinxql-query-builder results into Laravel collections or paginators.INSERT/UPDATE/DELETE. Batch operations may fail partially.mysqli/PDO calls.->compile()->getCompiled()) for performance-sensitive use cases.CursorPaginator) be supported for SphinxQL queries?MATCH syntax errors) be translated into Laravel exceptions?SphinxQLException class be created?DatabaseMigrations, DatabaseTransactions)?RTINDEX, RTQUERY) that need custom implementation?percolate) be exposed in Laravel’s context?Redis).| Phase | Action | Tools/Libraries |
|---|---|---|
| Evaluation | Benchmark against raw SphinxQL and existing search solutions. | AB (Apache Benchmark), custom scripts |
| Proof of Concept | Integrate into a non-critical module (e.g., admin search). | Laravel Service Provider, Facade |
| Core Integration | Replace direct SphinxQL calls with the query builder. | Query Macros, Model Scopes |
| Feature Parity | Implement missing features (e.g., pagination, model hydration). | Custom Adapters, Laravel Collections |
| Performance Tuning | Optimize batch queries and connection pooling. | Laravel Horizon, SphinxQL profiling |
| Documentation | Update Laravel docs with SphinxQL query builder examples. | Markdown, Swagger (if using API) |
pdo_mysql or mysqli (enable in php.ini or Docker containers).pdo_mysql for consistency with Laravel’s default.RTINDEX in Manticore).config/search.php:
'connections' => [
'sphinx' => [
'driver' => 'foolz',
'host' => env('SPHINX_HOST', '127.0.0.1'),
'port' => env('SPHINX_PORT', 9306),
'charset' => 'utf8',
],
],
public function register() {
$this->app->bind('sphinx', function ($app) {
$config = config('search.connections.sphinx');
$conn = new \Foolz\SphinxQL\Drivers\Pdo\Connection();
$conn->setParams($config);
return new \Foolz\SphinxQL\SphinxQL($conn);
});
}
app/Facades/Search.php:
namespace App\Facades;
use Illuminate\Support\Facades\Facade;
class Search extends Facade {
protected static function getFacadeAccessor() { return 'sphinx'; }
}
How can I help you explore Laravel packages today?