spatie/laravel-site-search
Crawl and index your Laravel site for fast full-text search—like a private Google. Highly customizable crawling and indexing, with concurrent requests. Uses SQLite FTS5 by default (no external services), or Meilisearch for advanced features.
Search::query()) for frontend integration (e.g., Livewire, Inertia, or JavaScript).CrawlingStarted, PageCrawled, and CrawlingFinished events for extensibility (e.g., logging, analytics).CrawlOptions).schedule:run) or queue workers to avoid stale indexes.SearchServiceProvider with bindings for Search and Crawler.spatie:crawl for manual triggers; spatie:crawl-schedule for automated runs.spatie:crawl-worker) for concurrent crawling.Search::query() in components.GET /search?q=term).storage/app/search.sqlite.meilisearch/meilisearch-php) and config (MEILISEARCH_URL).DB::where() queries) with spatie/laravel-site-search.Search facade to use Meilisearch via .env:
SEARCH_DRIVER=meilisearch
MEILISEARCH_URL=http://meilisearch:7700
meilisearch/meilisearch-php (≥v0.25).symfony/dom-crawler and guzzlehttp/guzzle (handled via Composer)./search) don’t clash with app routes.composer require spatie/laravel-site-search.php artisan vendor:publish --provider="Spatie\SiteSearch\SiteSearchServiceProvider".config/site-search.php (routes, excluded paths, drivers).CrawlMap in app/Providers/SiteSearchServiceProvider.php:
public function boot(): void
{
SiteSearch::crawlMap(function (CrawlMap $map) {
$map->route('/posts/{post}', Post::class);
$map->route('/docs/*', DocumentationPage::class);
});
}
php artisan spatie:crawl.app/Console/Kernel.php:
$schedule->command('spatie:crawl')->daily();
<form action="/search" method="GET">
<input type="text" name="q">
</form>
routes/web.php):
Route::get('/search', [SearchController::class, 'index']);
public function index(Request $request)
{
$results = Search::query($request->q)->get();
return view('search.results', compact('results'));
}
CrawlingStarted).spatie:crawl jobs in Laravel Horizon or queue workers.CrawlMap and excluded routes in feature flags or migration docs.storage/logs/laravel.log for CrawlFailed events.Search::query() returns expected results; test with Search::getIndexedPages().MAX_CONCURRENT_REQUESTS in config (default: 5).How can I help you explore Laravel packages today?