PHPackages                             digitlab/search-parser - 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. digitlab/search-parser

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

digitlab/search-parser
======================

Search string parser for Laravel.

v1.0.0(10y ago)413MITPHPPHP &gt;=5.6

Since Apr 22Pushed 10y agoCompare

[ Source](https://github.com/DigitLab/search-parser)[ Packagist](https://packagist.org/packages/digitlab/search-parser)[ Docs](http://digitlab.co.za)[ RSS](/packages/digitlab-search-parser/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Search Parser
=============

[](#search-parser)

[![StyleCI](https://camo.githubusercontent.com/1419338c01b73bc5028efcaa92b444b23487d91d054f71bfc33a1b0507850613/68747470733a2f2f7374796c6563692e696f2f7265706f732f35363832393739312f736869656c643f7374796c653d666c6174)](https://styleci.io/repos/56829791)[![Build Status](https://camo.githubusercontent.com/06eb87e177eedf5c1fe136b79840449649280bca6a00c3e6f1053fc16c7d9acf/68747470733a2f2f7472617669732d63692e6f72672f44696769744c61622f7365617263682d7061727365722e737667)](https://travis-ci.org/laravel/framework)[![Total Downloads](https://camo.githubusercontent.com/b8df9a6a8c61b2b9b3eba3cb37a7678b29a45ec79efe72dad93dc180af41b9aa/68747470733a2f2f706f7365722e707567782e6f72672f64696769746c61622f7365617263682d7061727365722f646f776e6c6f616473)](https://packagist.org/packages/digitlab/search-parser)[![Latest Stable Version](https://camo.githubusercontent.com/7de882a87b55d5ba191b48cc96cd322e54722b8c2def834d751ea76bf1d0a915/68747470733a2f2f706f7365722e707567782e6f72672f64696769746c61622f7365617263682d7061727365722f762f737461626c65)](https://packagist.org/packages/digitlab/search-parser)[![License](https://camo.githubusercontent.com/716ba5a9cfcf5aa1e883481d61dc36f307adea1b0917cba52c2a97e26b53e68d/68747470733a2f2f706f7365722e707567782e6f72672f64696769746c61622f7365617263682d7061727365722f6c6963656e7365)](https://packagist.org/packages/digitlab/search-parser)

Parses Lucene/Google style search strings into PostgresSQL full text query string.

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

[](#installation)

Install using composer:

```
composer require digitlab/search-parser
```

Add the service provider in app/config/app.php:

```
DigitLab\SearchParser\SearchParserServiceProvider::class,
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

To just parse a full text query you can simply use SearchParser:

```
$parser = new SearchParser();
$filters = $parser->parse('string to parse');
```

will produce

```
[
    'search' => 'string&to&parse'
]
```

### Filters

[](#filters)

To handle filters you need to extend SearchParser and add a handle function or add a pass through filter:

```
class CustomSearchParser extends SearchParser
{
    /**
     * The filters that should be returned without handlers.
     *
     * @var array
     */
    protected $passthruFilters = ['other'];

    /**
     * Handle the state filter.
     *
     * @param mixed $state
     * @return array
     */
    protected function handleState($state)
    {
        return ['some' => $state];
    }
}
```

```
$parser = new CustomSearchParser();
$filters = $parser->parse('state:pending other:string string to parse');
```

will produce

```
[
    'search' => 'string&to&parse',
    'some' => 'pending',
    'other' => 'string'
]
```

### Custom Query Key

[](#custom-query-key)

You can customise the array key of the query by overriding the `$queryName` variable in your custom class.

```
class CustomSearchParser extends SearchParser
{
    /**
     * The name of the query in the result array.
     *
     * @var string
     */
    protected $queryName = 'other';
}
```

```
$parser = new CustomSearchParser();
$filters = $parser->parse('string to parse');
```

will produce

```
[
    'other' => 'string&to&parse'
]
```

License
-------

[](#license)

Adaptive View is licensed under [The MIT License (MIT)](LICENSE).

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3721d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2621932?v=4)[DigitLab](/maintainers/digitlab)[@DigitLab](https://github.com/DigitLab)

---

Top Contributors

[![nrwiersma](https://avatars.githubusercontent.com/u/644536?v=4)](https://github.com/nrwiersma "nrwiersma (4 commits)")

---

Tags

searchlaravelparser

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mailerlite/laravel-elasticsearch

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

935572.3k2](/packages/mailerlite-laravel-elasticsearch)[algolia/scout-extended

Scout Extended extends Laravel Scout adding algolia-specific features

4186.6M6](/packages/algolia-scout-extended)[jeroen-g/explorer

Next-gen Elasticsearch driver for Laravel Scout.

399654.3k](/packages/jeroen-g-explorer)[remoblaser/search

A simple to implement Search for your Application

101.5k](/packages/remoblaser-search)

PHPackages © 2026

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