PHPackages                             sawmainek/laravel-scout-tntsearch-driver - 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. sawmainek/laravel-scout-tntsearch-driver

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

sawmainek/laravel-scout-tntsearch-driver
========================================

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

v8.4.1(5y ago)0110MITPHPPHP &gt;=7.1

Since Aug 16Pushed 5y agoCompare

[ Source](https://github.com/SawMaineK/laravel-scout-tntsearch-driver)[ Packagist](https://packagist.org/packages/sawmainek/laravel-scout-tntsearch-driver)[ RSS](/packages/sawmainek-laravel-scout-tntsearch-driver/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (10)Versions (55)Used By (0)

TNTSearch Driver for Laravel Scout - Laravel 5.3 - 7.0
======================================================

[](#tntsearch-driver-for-laravel-scout---laravel-53---70)

[![Backers on Open Collective](https://camo.githubusercontent.com/6b50eff556493032390f444d0a525e4276ce7b79b2e3754db26dac35134efb18/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f6c61726176656c2d73636f75742d746e747365617263682d6472697665722f6261636b6572732f62616467652e737667)](#backers) [![Sponsors on Open Collective](https://camo.githubusercontent.com/e7b531f6ad952fc6550a9a5729651d3fe1376e99555078d8dc6c25241e5d51b4/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f6c61726176656c2d73636f75742d746e747365617263682d6472697665722f73706f6e736f72732f62616467652e737667)](#sponsors) [![Latest Version on Packagist](https://camo.githubusercontent.com/8986de467b88076d8b87190a2d114c2162b0d7cebe1da8771bc8cf9c45f5989c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7465616d746e742f6c61726176656c2d73636f75742d746e747365617263682d6472697665722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/teamtnt/laravel-scout-tntsearch-driver)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/b83821d064a5acda15b880cd7010160728e8985daa4f3da2f05f76f18991900a/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7465616d746e742f6c61726176656c2d73636f75742d746e747365617263682d6472697665722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/teamtnt/laravel-scout-tntsearch-driver)[![Quality Score](https://camo.githubusercontent.com/e319f9243930e0ad841cda80f813bcc9f99259b7129f139c3f690f948cea44b3/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7465616d746e742f6c61726176656c2d73636f75742d746e747365617263682d6472697665722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/teamtnt/laravel-scout-tntsearch-driver)[![Total Downloads](https://camo.githubusercontent.com/4c0253b3ec619cc7dbaa20a75bac54c41d04d6b35c54f4e4be071192f461167c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7465616d746e742f6c61726176656c2d73636f75742d746e747365617263682d6472697665722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/teamtnt/laravel-scout-tntsearch-driver)

This package makes it easy to add full text search support to your models with Laravel 5.3 to 7.0.

Support us on Open Collective
-----------------------------

[](#support-us-on-open-collective)

- [TNTSearch](https://opencollective.com/tntsearch)

Contents
--------

[](#contents)

- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require sawmainek/laravel-scout-tntsearch-driver
```

Add the service provider:

```
// config/app.php
'providers' => [
    // ...
    TeamTNT\Scout\TNTSearchScoutServiceProvider::class,
],
```

Ensure you have Laravel Scout as a provider too otherwise you will get an "unresolvable dependency" error

```
// config/app.php
'providers' => [
    // ...
    Laravel\Scout\ScoutServiceProvider::class,
],
```

Add `SCOUT_DRIVER=tntsearch` to your `.env` file

Then you should publish `scout.php` configuration file to your config directory

```
php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"
```

In your `config/scout.php` add:

```
'tntsearch' => [
    'storage'  => storage_path(), //place where the index files will be stored
    'fuzziness' => env('TNTSEARCH_FUZZINESS', false),
    'fuzzy' => [
        'prefix_length' => 2,
        'max_expansions' => 50,
        'distance' => 2
    ],
    'asYouType' => false,
    'searchBoolean' => env('TNTSEARCH_BOOLEAN', false),
],
```

To prevent your search indexes being commited to your project repository, add the following line to your `.gitignore` file.

`/storage/*.index`

The `asYouType` option can be set per model basis, see the example below.

Usage
-----

[](#usage)

After you have installed scout and the TNTSearch driver, you need to add the `Searchable` trait to your models that you want to make searchable. Additionaly, define the fields you want to make searchable by defining the `toSearchableArray` method on the model:

```
