PHPackages                             emild/laravel-fulltext - 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. emild/laravel-fulltext

ActiveLibrary

emild/laravel-fulltext
======================

Fulltext indexing and searching for Laravel

1.7(4y ago)053MITPHPPHP &gt;=7.2

Since Nov 7Pushed 4y agoCompare

[ Source](https://github.com/emildayan/laravel-fulltext)[ Packagist](https://packagist.org/packages/emild/laravel-fulltext)[ Docs](https://github.com/swisnl/laravel-fulltext)[ RSS](/packages/emild-laravel-fulltext/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (7)Versions (33)Used By (0)

Laravel fulltext index and search
=================================

[](#laravel-fulltext-index-and-search)

[![Latest Version on Packagist](https://camo.githubusercontent.com/631eee7acd566a03440aa0d460970b128674eb8edd483f86e001978ae3f41b0e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737769736e6c2f6c61726176656c2d66756c6c746578742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/swisnl/laravel-fulltext)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/60b45ca75d816b840f908c496853667d680db5550017be5ecaef54d388900135/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f737769736e6c2f6c61726176656c2d66756c6c746578742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/swisnl/laravel-fulltext)[![Total Downloads](https://camo.githubusercontent.com/2512b9c20e91f57dd90550cf096d11e69e522670e9007fef75fc4909706215d0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f737769736e6c2f6c61726176656c2d66756c6c746578742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/swisnl/laravel-fulltext)[![Made by SWIS](https://camo.githubusercontent.com/6834ce71b23196ed946cb5d56fffec40ec67a7628b6239aa30d5dc0841e32f67/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2546302539462539412538302d6d6164652532306279253230535749532d2532334439303231422e7376673f7374796c653d666c61742d737175617265)](https://www.swis.nl)

This package creates a MySQL fulltext index for models and enables you to search through those.

Install
-------

[](#install)

1. Install with composer `composer require swisnl/laravel-fulltext`.
2. Publish migrations and config `php artisan vendor:publish --tag=laravel-fulltext`
3. Migrate the database `php artisan migrate`

Usage
-----

[](#usage)

The package uses a model observer to update the index when models change. If you want to run a full index you can use the console commands.

### Models

[](#models)

Add the `Indexable` trait to the model you want to have indexed and define the columns you'd like to index as title and content.

#### Example

[](#example)

```
class Country extends Model
{

    use \Swis\Laravel\Fulltext\Indexable;

    protected $indexContentColumns = ['biographies.name', 'political_situation', 'elections'];
    protected $indexTitleColumns = ['name', 'governmental_type'];

}

```

You can use a dot notitation to query relationships for the model, like `biographies.name`.

### Searching

[](#searching)

You can search using the Search class.

```
$search = new \Swis\Laravel\Fulltext\Search();
$search->run('europe');

```

This will return a Collection of `\Swis\Laravel\Fulltext\IndexedRecord` which contain the models in the Polymorphic relation `indexable`.

If you only want to search a certain model you can use `$search->runForClass('europe', Country::class);`. This will only return results from that model.

### Commands

[](#commands)

#### laravel-fulltext:all

[](#laravel-fulltextall)

Index all models for a certain class

```
 php artisan  laravel-fulltext:all

Usage:
  laravel-fulltext:all

Arguments:
  model_class           Classname of the model to index

```

#### Example

[](#example-1)

`php artisan  laravel-fulltext:all \\App\\Models\\Country`

#### laravel-fulltext:one

[](#laravel-fulltextone)

```

Usage:
  laravel-fulltext:one

Arguments:
  model_class           Classname of the model to index
  id                    ID of the model to index

```

#### Example

[](#example-2)

`php artisan  laravel-fulltext:one \\App\\Models\\Country 4`

Options
-------

[](#options)

### db\_connection

[](#db_connection)

Choose the database connection to use, defaults to the default database connection. When you are NOT using the default database connection, this MUST be set before running the migration to work correctly.

### weight.title weight.content

[](#weighttitle-weightcontent)

Results on `title` or `content` are weighted in the results. Search result score is multiplied by the weight in this config

### enable\_wildcards

[](#enable_wildcards)

Enable wildcard after words. So when searching for for example `car` it will also match `carbon`.

### exclude\_feature\_enabled

[](#exclude_feature_enabled)

This feature excludes some rows from being returned. Enable this when you have a flag in your model which determines whether this record must be returned in search queries or not. By default this feature is disabled.

### exclude\_records\_column\_name

[](#exclude_records_column_name)

The column name for that property (which acts as a flag). This must match the exact column name at the table.

#### An example of using this feature

[](#an-example-of-using-this-feature)

Think about when you have a blog and then you add this search functionality to your blogging system to search through your blog posts. Sometimes you do not want some posts to be appeared in search result, for example when a post is not published yet. This feature helps you to do it.

Change log
----------

[](#change-log)

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

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Björn Brala](https://github.com/swisnl)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

SWIS
----

[](#swis)

[SWIS](https://www.swis.nl) is a web agency from Leiden, the Netherlands. We love working with open source software.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity69

Established project with proven stability

 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

Every ~62 days

Recently: every ~15 days

Total

31

Last Release

1596d ago

Major Versions

0.21.0 → 1.12021-09-21

PHP version history (4 changes)0.1.1PHP &gt;=5.6

0.14.0PHP &gt;=7.0

0.16.0PHP &gt;=7.1.3

0.21.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/e6c7f108921fcc361888d767b82ea328ad14ce69097d2e95a5d0e9f63cb2a9dd?d=identicon)[emild](/maintainers/emild)

---

Top Contributors

[![JaZo](https://avatars.githubusercontent.com/u/3475007?v=4)](https://github.com/JaZo "JaZo (49 commits)")[![bbrala](https://avatars.githubusercontent.com/u/3294970?v=4)](https://github.com/bbrala "bbrala (35 commits)")[![emildayan](https://avatars.githubusercontent.com/u/22715782?v=4)](https://github.com/emildayan "emildayan (13 commits)")[![samberrry](https://avatars.githubusercontent.com/u/20775532?v=4)](https://github.com/samberrry "samberrry (6 commits)")[![vblinden](https://avatars.githubusercontent.com/u/1420356?v=4)](https://github.com/vblinden "vblinden (5 commits)")[![bingvanmoorsel](https://avatars.githubusercontent.com/u/4376490?v=4)](https://github.com/bingvanmoorsel "bingvanmoorsel (3 commits)")[![marijnz0r](https://avatars.githubusercontent.com/u/12230678?v=4)](https://github.com/marijnz0r "marijnz0r (2 commits)")[![PrinsFrank](https://avatars.githubusercontent.com/u/25006490?v=4)](https://github.com/PrinsFrank "PrinsFrank (2 commits)")[![RoachMech](https://avatars.githubusercontent.com/u/7983727?v=4)](https://github.com/RoachMech "RoachMech (1 commits)")[![mattdinthehouse](https://avatars.githubusercontent.com/u/6799224?v=4)](https://github.com/mattdinthehouse "mattdinthehouse (1 commits)")[![barryatswisnl](https://avatars.githubusercontent.com/u/18284224?v=4)](https://github.com/barryatswisnl "barryatswisnl (1 commits)")

---

Tags

swisnllaravel-fulltext

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/emild-laravel-fulltext/health.svg)

```
[![Health](https://phpackages.com/badges/emild-laravel-fulltext/health.svg)](https://phpackages.com/packages/emild-laravel-fulltext)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M529](/packages/laravel-passport)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M106](/packages/laravel-cashier)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[swisnl/laravel-fulltext

Fulltext indexing and searching for Laravel

184104.5k5](/packages/swisnl-laravel-fulltext)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)

PHPackages © 2026

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