sarfraznawaz2005/indexer
A lightweight Laravel package that indexes Eloquent model records into a dedicated table, adding fast, database-backed search to your app without external services like Elasticsearch or Algolia.
Install into a non-production environment first — this tool is for development/staging, not live traffic:
composer require sarfraznawaz2005/indexer
Publish the config (and migrations, if the package ships a storage table):
php artisan vendor:publish --provider="Sarfraznawaz2005\Indexer\IndexerServiceProvider"
php artisan migrate
Register the middleware. The package hooks into the request lifecycle to observe SELECT queries. In older Laravel add it to the web group in app/Http/Kernel.php; in Laravel 11+ use bootstrap/app.php via ->withMiddleware(...). Check config/indexer.php for the enabled flag and any route/dashboard toggle.
Look first at: config/indexer.php (enable/disable, storage driver, route prefix) and the published migrations. That tells you whether results land in a DB table you can query directly or are exposed through a UI route / artisan command.
First use case: boot your app locally, click through your slowest screens (a listing page, a search form, a report), then open the dashboard/command the README documents and read the suggested index columns. You're looking for WHERE, ORDER BY, GROUP BY, and JOIN ... ON columns that lack an index.
Schema::table('orders', function (Blueprint $table) {
$table->index(['customer_id', 'created_at']); // composite, ordered by selectivity
});
Keep them in versioned migrations, never applied ad-hoc.web group so it sees session-authenticated queries; putting it on api will miss everything behind your UI. If you only want one feature analyzed, add it as route middleware to that group instead.DB::table(...)->truncate()) to reset between analysis rounds, otherwise stale suggestions from an old schema pollute the review.EXPLAIN output. The package's suggestion list should shrink; if a suggested column keeps reappearing, the index likely isn't being used (see gotchas).APP_ENV in config and treat that as a hard rule.boot()/middleware registration or the route file. If it breaks, the fix is usually a one-liner in an app-level service provider — but budget for it before committing.? placeholders, so suggestions are structural: it can tell you orders.status is filtered, but not that 99% of rows are one status (a bad index candidate). Sanity-check selectivity with SELECT COUNT(DISTINCT col)/COUNT(*) before indexing.information_schema for existing indexes.SHOW INDEX FROM table before adding duplicates — a redundant left-prefix index wastes write throughput.php artisan config:clear (or config:cache in CI); the middleware's enabled flag is read from config at boot.LIKE-heavy search queries or queries against sessions/cache/jobs tables). The config file typically exposes column/keyword allow-lists for exactly this.EXPLAIN, always. A suggested index that MySQL won't use (low cardinality, leading wildcard LIKE '%x', functions on the column) is worse than none — it costs write performance and disk for nothing.How can I help you explore Laravel packages today?