PHPackages                             plusinfolab/search - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. plusinfolab/search

ActiveLibrary[Search &amp; Filtering](/categories/search)

plusinfolab/search
==================

Advanced search package for Laravel with multiple algorithms, Eloquent integration, and SQLite FTS support

1.0.0(5mo ago)048[1 PRs](https://github.com/plusinfolab/search/pulls)MITPHPPHP ^8.2CI passing

Since Dec 5Pushed 1mo agoCompare

[ Source](https://github.com/plusinfolab/search)[ Packagist](https://packagist.org/packages/plusinfolab/search)[ Docs](https://github.com/plusinfolab/search)[ GitHub Sponsors](https://github.com/plusinfolab)[ RSS](/packages/plusinfolab-search/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (13)Versions (3)Used By (0)

Laravel Advanced Search
=======================

[](#laravel-advanced-search)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8a1bec3703502855ebeca41052e669ccfb999cf4f494f513fecd111813f1d5f2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706c7573696e666f6c61622f7365617263682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/plusinfolab/search)[![GitHub Tests Action Status](https://camo.githubusercontent.com/de615599667da9d570dd512935a6aa137699764abf137722159aafab3447fdaf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706c7573696e666f6c61622f7365617263682f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/plusinfolab/search/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/a9b7cca3ab7bf79edeb114d1290ef1624a0094fb9814bb501170dcebdd1769df/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706c7573696e666f6c61622f7365617263682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/plusinfolab/search)[![License](https://camo.githubusercontent.com/7c957586dd850d5cba18ce71edcd632eb13f8d558a4809613ccb345f584eebb9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f706c7573696e666f6c61622f7365617263682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/plusinfolab/search)[![PHP Version](https://camo.githubusercontent.com/4e2d2b85edf0f5058aeeef2549151665889f7e807ec4d1383ac8237097b617fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f706c7573696e666f6c61622f7365617263682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/plusinfolab/search)

A comprehensive, production-ready search solution for Laravel applications with **9 powerful search algorithms**, seamless **Eloquent integration**, and **SQLite FTS support**. Make searching in your Laravel apps incredibly easy and powerful—**no external services required**!

✨ Features
----------

[](#-features)

### 🔍 Multiple Search Algorithms

[](#-multiple-search-algorithms)

- **Exact Match** - Perfect for precise searches
- **Partial Match** - Substring matching with intelligent scoring
- **Prefix/Suffix** - Great for autocomplete
- **Fuzzy Search** - Levenshtein distance for typo tolerance
- **Trigram Search** - Advanced similarity matching
- **Boolean Search** - AND/OR/NOT operators with phrase support
- **Regex Search** - Pattern matching with safety checks
- **Phonetic Search** - Soundex/Metaphone for "sounds-like" searches

### 🚀 Advanced Features

[](#-advanced-features)

- **Smart Ranking** - Multi-factor scoring (algorithm weights, field weights, recency, popularity)
- **Result Highlighting** - Automatic highlighting of matched terms
- **Search Suggestions** - Autocomplete and "did you mean" functionality
- **Synonym Expansion** - Configurable synonym dictionaries
- **Caching** - Built-in result caching for performance
- **Search History** - Track and analyze search queries

### 💎 Eloquent Integration

[](#-eloquent-integration)

- Simple `Searchable` trait for models
- Fluent query builder API
- Automatic index synchronization
- Configurable field weights
- No external dependencies required!

### 🗄️ SQLite FTS Support

[](#️-sqlite-fts-support)

- Automatic FTS5 table creation
- Real-time index synchronization
- Optimized full-text search

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require plusinfolab/search
```

Publish the configuration file:

```
php artisan vendor:publish --tag="search-config"
```

Optionally, publish and run migrations for search history:

```
php artisan vendor:publish --tag="search-migrations"
php artisan migrate
```

🚀 Quick Start
-------------

[](#-quick-start)

### 1. Make Your Model Searchable

[](#1-make-your-model-searchable)

```
use Illuminate\Database\Eloquent\Model;
use PlusInfoLab\Search\Traits\Searchable;

class Post extends Model
{
    use Searchable;

    // Define searchable fields
    protected $searchable = ['title', 'content', 'tags'];

    // Optional: Define field weights for ranking
    protected $searchWeights = [
        'title' => 10,    // Title matches score higher
        'content' => 5,   // Content matches score medium
        'tags' => 3,      // Tag matches score lower
    ];
}
```

### 2. Search Your Models

[](#2-search-your-models)

```
// Simple search using default algorithm (partial match)
$posts = Post::search('laravel')->get();

// Search with specific algorithm
$posts = Post::search('laravle', 'fuzzy')->get();

// Get search results with scores and metadata
$results = Post::searchQuery('laravel framework');

foreach ($results as $result) {
    echo $result->getItem()->title;
    echo "Score: " . $result->getScore();
    echo "Matched fields: " . implode(', ', $result->getMatchedFields());
}
```

📖 Usage Examples
----------------

[](#-usage-examples)

### Using the Search Facade

[](#using-the-search-facade)

```
use PlusInfoLab\Search\Facades\Search;

// Create a search query
$query = Search::query('laravel framework')
    ->in(['title', 'content'])
    ->weights(['title' => 10, 'content' => 5])
    ->using('fuzzy')
    ->minScore(0.5)
    ->limit(10);

// Execute search on Eloquent builder
$results = Search::search($query->setBuilder(Post::query()));
```

### Boolean Search

[](#boolean-search)

```
// AND operator
$posts = Post::search('laravel AND framework', 'boolean')->get();

// OR operator
$posts = Post::search('laravel OR symfony', 'boolean')->get();

// NOT operator
$posts = Post::search('framework NOT deprecated', 'boolean')->get();

// Complex queries with grouping
$posts = Post::search('(laravel OR symfony) AND framework NOT old', 'boolean')->get();

// Exact phrases
$posts = Post::search('"laravel framework" AND tutorial', 'boolean')->get();
```

### Fuzzy Search (Typo Tolerance)

[](#fuzzy-search-typo-tolerance)

```
// Will match "Laravel", "Laravle", "Laravell", etc.
$posts = Post::search('Laravle', 'fuzzy')->get();

// Configure threshold in config/search.php
'fuzzy' => [
    'threshold' => 2, // Maximum Levenshtein distance
],
```

### Phonetic Search (Sounds-Like)

[](#phonetic-search-sounds-like)

```
// Will match "Stephen", "Steven", "Stefan"
$users = User::search('Stephen', 'phonetic')->get();

// Configure algorithm (soundex or metaphone)
'phonetic' => [
    'algorithm' => 'metaphone', // or 'soundex'
],
```

### Prefix Search (Autocomplete)

[](#prefix-search-autocomplete)

```
// Match titles starting with "lar"
$posts = Post::search('lar', 'prefix')->get();
// Returns: "Laravel Tutorial", "Laravel Tips", etc.
```

### With Highlighting

[](#with-highlighting)

```
$results = Post::searchQuery('laravel framework');

foreach ($results as $result) {
    $highlights = $result->getHighlights();

    // Highlights contain matched fragments with  tags
    echo $highlights['title'][0];
    // Output: "The Laravel Framework Guide"
}
```

### Search Suggestions

[](#search-suggestions)

```
use PlusInfoLab\Search\Facades\Search;

// Get autocomplete suggestions
$suggestions = Search::suggest('larav', ['Laravel', 'JavaScript', 'Laravel Nova'], 5);
// Returns: ['Laravel', 'Laravel Nova']

// "Did you mean" functionality
$suggester = app(\PlusInfoLab\Search\Features\SearchSuggester::class);
$suggestion = $suggester->didYouMean('laravle', ['Laravel', 'Symfony', 'CodeIgniter']);
// Returns: 'Laravel'
```

### Synonym Expansion

[](#synonym-expansion)

```
// Configure synonyms in config/search.php
'synonyms' => [
    'enabled' => true,
    'dictionary' => [
        'car' => ['automobile', 'vehicle'],
        'phone' => ['mobile', 'smartphone', 'cellphone'],
    ],
],

// Search for "car" will also search for "automobile" and "vehicle"
$results = Product::searchQuery('car');
```

### Advanced Ranking

[](#advanced-ranking)

```
// Configure ranking in config/search.php
'ranking' => [
    'enabled' => true,

    // Boost recent results
    'recency_boost' => [
        'enabled' => true,
        'field' => 'created_at',
        'decay_days' => 30,
        'boost_factor' => 1.5,
    ],

    // Boost popular results
    'popularity_boost' => [
        'enabled' => true,
        'field' => 'views_count',
        'boost_factor' => 0.1,
    ],
],
```

### SQLite FTS Integration

[](#sqlite-fts-integration)

```
// Enable in config/search.php
'fts' => [
    'enabled' => true,
    'version' => 'fts5',
    'auto_sync' => true, // Automatically sync model changes
],

// FTS tables are created automatically
// Search uses FTS when available for better performance
$posts = Post::search('laravel')->get();
```

⚙️ Configuration
----------------

[](#️-configuration)

The package is highly configurable. Here are some key options:

```
// config/search.php

return [
    // Default search algorithm
    'default_algorithm' => 'partial',

    // Algorithm-specific settings
    'algorithms' => [
        'fuzzy' => [
            'threshold' => 2,
            'max_length' => 255,
        ],
        'trigram' => [
            'min_similarity' => 0.3,
        ],
        // ... more algorithms
    ],

    // Ranking configuration
    'ranking' => [
        'enabled' => true,
        'algorithm_weights' => [
            'exact' => 100,
            'prefix' => 80,
            'partial' => 60,
            'fuzzy' => 40,
        ],
    ],

    // Caching
    'cache' => [
        'enabled' => true,
        'ttl' => 3600,
    ],

    // Highlighting
    'highlighting' => [
        'enabled' => true,
        'prefix' => '',
        'suffix' => '',
    ],
];
```

🧪 Testing
---------

[](#-testing)

```
composer test
```

Run tests with coverage:

```
composer test-coverage
```

📊 Performance
-------------

[](#-performance)

- **Zero external dependencies** - Pure PHP implementation
- **Optimized algorithms** - Efficient string matching
- **Built-in caching** - Cache search results
- **FTS support** - Use SQLite FTS5 for large datasets
- **Configurable limits** - Prevent performance issues

🎯 Use Cases
-----------

[](#-use-cases)

- **E-commerce** - Product search with typo tolerance
- **Blog/CMS** - Content search with highlighting
- **Documentation** - Technical documentation search
- **User Directory** - Name search with phonetic matching
- **Knowledge Base** - Boolean search for complex queries
- **Autocomplete** - Prefix search for suggestions

📋 Requirements
--------------

[](#-requirements)

- PHP 8.2 or higher
- Laravel 11.x or 12.x
- SQLite 3.9.0+ (optional, for FTS support)

🧪 Testing
---------

[](#-testing-1)

Run the test suite:

```
composer test
```

Run tests with coverage:

```
composer test-coverage
```

Run static analysis:

```
composer analyse
```

📝 Changelog
-----------

[](#-changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Development Setup

[](#development-setup)

1. Clone the repository
2. Install dependencies: `composer install`
3. Run tests: `composer test`
4. Run static analysis: `composer analyse`
5. Format code: `composer format`

🔒 Security
----------

[](#-security)

If you discover any security issues, please email  instead of using the issue tracker.

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

🙏 Credits
---------

[](#-credits)

- [Aditya Jodhani](https://github.com/adityajodhani) - Creator &amp; Maintainer
- [PlusInfoLab](https://plusinfolab.in) - Development Company
- [All Contributors](../../contributors)

💬 Support
---------

[](#-support)

- **Issues**: [GitHub Issues](https://github.com/plusinfolab/search/issues)
- **Discussions**: [GitHub Discussions](https://github.com/plusinfolab/search/discussions)
- **Email**:

🌟 Why This Package?
-------------------

[](#-why-this-package)

Unlike other search solutions that require external services (Elasticsearch, Algolia) or complex setup, this package:

- ✅ Works out of the box with zero configuration
- ✅ No external dependencies or services required
- ✅ Multiple algorithms for different use cases
- ✅ Seamless Eloquent integration
- ✅ Production-ready with caching and optimization
- ✅ Highly configurable and extensible
- ✅ Comprehensive documentation and examples
- ✅ **100% Free and Open Source**

📈 Roadmap
---------

[](#-roadmap)

Future features planned:

- MySQL Full-Text Search integration
- PostgreSQL Full-Text Search integration
- Elasticsearch adapter
- Multi-language support
- Advanced analytics dashboard
- Performance monitoring tools

⭐ Show Your Support
-------------------

[](#-show-your-support)

If you find this package useful, please consider giving it a ⭐ on [GitHub](https://github.com/plusinfolab/search)!

---

**Make search awesome in your Laravel apps! 🚀**

**Version**: 1.0.0 | **Released**: December 2025 | **License**: MIT

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance82

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

164d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5704ae6235da3734f84e8db1db6e2e10a1a697dfde3643939386e7ccb374a795?d=identicon)[amjpdevp](/maintainers/amjpdevp)

---

Top Contributors

[![amjpdevp](https://avatars.githubusercontent.com/u/113779419?v=4)](https://github.com/amjpdevp "amjpdevp (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

searchlaravelplusinfolab

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/plusinfolab-search/health.svg)

```
[![Health](https://phpackages.com/badges/plusinfolab-search/health.svg)](https://phpackages.com/packages/plusinfolab-search)
```

###  Alternatives

[spatie/laravel-site-search

A site search engine

300129.1k](/packages/spatie-laravel-site-search)[mailerlite/laravel-elasticsearch

An easy way to use the official PHP ElasticSearch client in your Laravel applications.

934529.3k2](/packages/mailerlite-laravel-elasticsearch)[teamtnt/laravel-scout-tntsearch-driver

Driver for Laravel Scout search package based on https://github.com/teamtnt/tntsearch

1.1k2.5M28](/packages/teamtnt-laravel-scout-tntsearch-driver)[algolia/scout-extended

Scout Extended extends Laravel Scout adding algolia-specific features

4186.3M6](/packages/algolia-scout-extended)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[lacodix/laravel-model-filter

A Laravel package to filter, search and sort models with ease while fetching from database.

17649.9k](/packages/lacodix-laravel-model-filter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
