Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Sphinxsearch Bundle Laravel Package

iakumai/sphinxsearch-bundle

iakumai/sphinxsearch-bundle integrates Sphinx full-text search into Symfony apps, offering configurable indexes, indexing commands, and SphinxQL query support for fast, scalable search across Doctrine entities.

View on GitHub
Deep Wiki
Context7

Getting Started

Reality check first: this is a Symfony 2 bundle, not a Laravel package. There is no ServiceProvider, facade, publishable config, or artisan command. If you are on Laravel, you cannot composer require this and use it idiomatically — read the two sections below as a design reference rather than an install guide, and budget a 2–5 day spike to reimplement the useful slice (a SphinxQL client + an indexer command) natively.

If you are actually on Symfony 2.x:

  1. Install:
    composer require iakumai/sphinxsearch-bundle
    
  2. Register the bundle in app/AppKernel.php (namespace IAkumaI\SphinxsearchBundle; confirm the exact bundle class in the package root).
  3. Configure connection + indexes under the iakumai_sphinxsearch key in config.yml — searchd host/port. SphinxQL is typically 9306, the legacy SphinxAPI 9312.
  4. Clear the container cache, then verify the service is wired:
    app/console container:debug | grep -i sphinx
    

Where to look first (in this order):

  • README — quickstart, but examples drift between releases.
  • DependencyInjection/Configuration.php — the authoritative list of config keys. Trust this over blog posts.
  • Resources/config/services.yml — service IDs and constructor arguments.
  • The main service class — read it end-to-end; the whole bundle is small enough to digest in ~15 minutes. Do that before wiring anything, so you know what it actually gives you (very little beyond a wrapped PDO/mysqli client).

First use case — a keyword search page. Sphinx returns IDs and attributes only; you hydrate entities afterwards. A minimal SphinxQL query:

$rows = $sphinx->query(
    "SELECT id, WEIGHT() AS w FROM product_index " .
    "WHERE MATCH(:q) AND status = 1 " .
    "ORDER BY w DESC LIMIT 20 OFFSET 0",
    ['q' => $escapedUserQuery]
);

Note: indexer and your sphinx.conf are still entirely your responsibility — this bundle does not build or rotate indexes.

Implementation Patterns

Wrap it behind a SearchService. Inject the bundle service into one application-level class (or a repository). Controllers call $searchService->findProducts($term, $page) — never build SphinxQL inline. That single seam is where you escape input, enforce limits, and later swap the backend.

Two-phase search is the standard shape. Sphinx returns id + attributes only, so:

$rows = $sphinx->query($sql, $params);
$ids  = array_column($rows, 'id');

$products = $repo->findByIds($ids);           // WHERE id IN (:ids)
// reorder $products to match $ids — this preserves Sphinx relevance ranking

Do not rely on the DB to re-sort; Sphinx's WEIGHT() order is the ranking you paid for.

Use SphinxQL for everything you can. Attribute filters, ranges, sorting, GROUP BY, IN(), and @field syntax all work. Keep the legacy SphinxAPI client only for a feature it uniquely exposes — mixing both keeps two connection/port configs alive and doubles your escaping surface.

Indexer abstraction as a workflow. The bundle's IndexerInterface idea is the reusable bit: each implementation returns source rows the indexer binary consumes. Model your indexing as:

  • Full reindex — nightly indexer --all into a shadow index, then indexer --rotate to swap atomically. Never index in place on a live index.
  • Delta / incremental — track a max(id) or updated_at watermark per index; index only changes, then merge.
  • Chunked reads — pull source rows in batches (e.g. 5k) rather than materializing a full table; PHP memory will otherwise blow up on large corpora.

Integration tips.

  • Keep search out of your request-critical DB transaction; it's an eventual-consistency store.
  • Expose search config (hosts, index names) via env vars, not a hardcoded sphinx.conf path, so container/CI environments are portable.
  • If you migrate to Manticore Search (SphinxQL-compatible and maintained), this exact query shape carries over — write your SphinxClient against a narrow interface (query(string $sql, array $params): array) so the backend stays swappable.

Gotchas and Tips

Framework mismatch (the big one). Pulling Symfony DI into Laravel is a permanent tax for no gain. The bundle's container contracts do not translate; you would be bypassing it anyway. Reimplement the ~20% you need.

Index staleness. Batch indexing means results lag the DB by your cron interval. That is fine for a catalog, unacceptable for inventory or availability. Decide up front whether you need RT (real-time) indexes; the bundle does not help you configure them.

Daemon unavailability is a hard failure. If searchd is down, every search request throws — the package provides no fallback. Implement a degraded-mode path (LIKE/DB full-text fallback) before launch, not after the first incident. Wrap the client call in try/catch and log.

Schema drift fails silently. If your index definition diverges from source columns, you get empty results, not errors — the worst failure mode. Add a canary test that queries known IDs and asserts counts after every reindex. Pin the sphinx.conf under version control.

MATCH syntax errors from user input. User-supplied strings passed raw into MATCH() raise exceptions or return garbage. Normalize and escape: strip Sphinx operators (@, !, ~, -, quotes, *) unless you're deliberately exposing them, and wrap terms defensively.

Memory pressure during indexing. Loading a full source result set exhausts PHP memory on real data. Chunk it. The bundle does not implement this for you.

Config keys vary between releases. Always confirm keys against DependencyInjection/Configuration.php for the pinned version — examples online mix versions.

PHP 8 / modern Symfony. Expect reserved-word collisions and strict-type breakage; the package targets PHP 5.x-era idioms and Symfony 2 service XML. Audit before assuming it runs. Pin and vendor it if you depend on it.

Support surface is essentially zero. 27 stars, 0 dependents, effectively unmaintained upstream (Sphinx 2.x; community moved to Manticore). Treat it as owned-by-you code: fork, vendor, name an internal owner, and document the exit path (Manticore + thin client, or Meilisearch/Typesense for product search).

Extension points are just the DI service and the indexer interface — there is nothing elaborate to hook into. Build your abstraction above the bundle, not by extending it.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core