PHPackages                             chrisreedio/laravel-scout-keys - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. chrisreedio/laravel-scout-keys

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

chrisreedio/laravel-scout-keys
==============================

Provides user level tenant tokens / scoped search keys.

v1.0.0-beta.6(1y ago)149[6 PRs](https://github.com/chrisreedio/laravel-scout-keys/pulls)1MITPHPPHP ^8.2CI passing

Since Sep 17Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/chrisreedio/laravel-scout-keys)[ Packagist](https://packagist.org/packages/chrisreedio/laravel-scout-keys)[ Docs](https://github.com/chrisreedio/laravel-scout-keys)[ GitHub Sponsors]()[ RSS](/packages/chrisreedio-laravel-scout-keys/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (17)Versions (13)Used By (1)

Laravel Scout User Keys/Tokens
==============================

[](#laravel-scout-user-keystokens)

[![Latest Version on Packagist](https://camo.githubusercontent.com/520d1f8c0cc2213c7d4acfc5d3c79f0c7fc0b225f78ab7736a605635ab221de4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636872697372656564696f2f6c61726176656c2d73636f75742d6b6579732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chrisreedio/laravel-scout-keys)[![GitHub Tests Action Status](https://camo.githubusercontent.com/19942b6925a33374f30feb068e4e3e9c569d19eb17e85dbba36f4fbb81d16372/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636872697372656564696f2f6c61726176656c2d73636f75742d6b6579732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/chrisreedio/laravel-scout-keys/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a1eb47f2ee0fd85847a7c17c216ff8d3ec9b1d20deecc763886b04d7508fcb54/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636872697372656564696f2f6c61726176656c2d73636f75742d6b6579732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/chrisreedio/laravel-scout-keys/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/b5948604a39ef13c3ca71bb87694556fea414cea854bcf0da6e307a3a59deeb6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636872697372656564696f2f6c61726176656c2d73636f75742d6b6579732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chrisreedio/laravel-scout-keys)

This package provides user level tenant tokens / scoped search keys for Laravel Scout.

The current implementation supports the Meilisearch and Typesense drivers.

### TODO

[](#todo)

- Add support for runtime configuration of generated key facets/filtered attributes

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

[](#installation)

You can install the package via composer:

```
composer require chrisreedio/laravel-scout-keys
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="laravel-scout-keys-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-scout-keys-config"
```

This is the contents of the published config file:

```
return [
     /**
     * Whether to register the Scout Indexing commands for use via web.
     */
    'register_commands' => false,

    'key' => [
        /**
         * The number of minutes a search key should be valid for.
         */
        'lifetime' => env('SCOUT_KEY_EXPIRATION', 60 * 12),
    ],
];
```

Usage
-----

[](#usage)

Add the `SearchUser` interface and `HasSearchKeys` trait to your `User` model(s).

Example:

```
class User extends Authenticatable SearchUser
{
    use HasFactory, HasSearchKeys;
    // ...
}
```

Finally, add the following to your `web.php` routes file:

```
ScoutKeys::getRoute();
```

If you'd like to change the default path of `/search/key`, you may pass the desired path as the first argument to the `getRoute` method.

```
ScoutKeys::getRoute('dashboard/search/key');
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Chris Reed](https://github.com/chrisreedio)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance67

Regular maintenance activity

Popularity11

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 72.2% of commits — single point of failure

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 ~3 days

Total

6

Last Release

587d ago

### Community

Maintainers

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

---

Top Contributors

[![chrisreedio](https://avatars.githubusercontent.com/u/77644584?v=4)](https://github.com/chrisreedio "chrisreedio (26 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

laravelChris Reedlaravel-scout-keys

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/chrisreedio-laravel-scout-keys/health.svg)

```
[![Health](https://phpackages.com/badges/chrisreedio-laravel-scout-keys/health.svg)](https://phpackages.com/packages/chrisreedio-laravel-scout-keys)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[jeffgreco13/filament-breezy

A custom package for Filament with login flow, profile and teams support.

1.0k1.7M41](/packages/jeffgreco13-filament-breezy)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[ryangjchandler/laravel-cloudflare-turnstile

A simple package to help integrate Cloudflare Turnstile.

438896.6k2](/packages/ryangjchandler-laravel-cloudflare-turnstile)[spatie/laravel-passkeys

Use passkeys in your Laravel app

444494.4k16](/packages/spatie-laravel-passkeys)

PHPackages © 2026

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