PHPackages                             liqueurdetoile/cakephp-fuse - 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. [Database &amp; ORM](/categories/database)
4. /
5. liqueurdetoile/cakephp-fuse

ActiveCakephp-plugin[Database &amp; ORM](/categories/database)

liqueurdetoile/cakephp-fuse
===========================

Cakephp 3/4 plugin that implements fuzzy search based on Fuse

1.0.2(4y ago)1571MITPHPPHP &gt;=7.1CI failing

Since Nov 17Pushed 4y ago1 watchersCompare

[ Source](https://github.com/liqueurdetoile/cakephp-fuse)[ Packagist](https://packagist.org/packages/liqueurdetoile/cakephp-fuse)[ RSS](/packages/liqueurdetoile-cakephp-fuse/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (5)Versions (4)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/166fe858edb7a71a19dc1cb886c53db3728e8489b654cb2a5a7418df0020cbd4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6c6971756575726465746f696c652f63616b657068702d667573652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/liqueurdetoile/cakephp-fuse)[![Build Status](https://camo.githubusercontent.com/16efc774b94b04dce07fd9481bf894544c24b800b0acb6c4066e961ae35f835d/68747470733a2f2f7472617669732d63692e636f6d2f6c6971756575726465746f696c652f63616b657068702d667573652e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/liqueurdetoile/cakephp-fuse)[![Coverage Status](https://camo.githubusercontent.com/8456e3fcb2ffd0db2909969901e6a74bc6aea01c524e1bee4f75f91c86ec3467/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6c6971756575726465746f696c652f63616b657068702d667573652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/liqueurdetoile/cakephp-fuse?branch=master)[![license](https://camo.githubusercontent.com/196b5d9509f5c2dfde81dd36f8c6ed28cf4456db0911c8471991adb834f4c7dc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6c6971756575726465746f696c652f63616b657068702d667573652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/liqueurdetoile/cakephp-fuse)

Cakephp-fuse plugin for CakePHP
===============================

[](#cakephp-fuse-plugin-for-cakephp)

This plugin is a simple wrapper behavior around [Fuse](https://github.com/loilo/Fuse) to implement fuzzy search within any model. Searches can only be performed on strings.

**This behavior requires at least PHP 7.1 and can only be used with Cakephp 3.x and 4.x branches.**

- [Cakephp-fuse plugin for CakePHP](#cakephp-fuse-plugin-for-cakephp)
    - [Installation](#installation)
    - [Usage](#usage)
        - [Basic usage](#basic-usage)
        - [Persistent configuration](#persistent-configuration)
        - [Nested associations](#nested-associations)
        - [Autokeys detection](#autokeys-detection)
    - [API cheatsheet](#api-cheatsheet)
    - [CHANGELOG](#changelog)

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

[](#installation)

You can install this plugin into your CakePHP application using [composer](https://getcomposer.org).

The recommended way to install composer packages is:

```
composer require liqueurdetoile/cakephp-fuse

```

The plugin itself is only a behavior that [can be attached to any model](https://book.cakephp.org/4/en/orm/behaviors.html) in the `initialize` method :

```
$this->addBehavior('Lqdt/CakephpFuse.Fuse');
```

Behavior can also be attached *on-the-fly* as it does not require any additional initialize operations.

Usage
-----

[](#usage)

### Basic usage

[](#basic-usage)

The behavior provides a `fuse` method on the model to get back a configured query. For convenience a custom finder is also available. The two following calls are totally equivalent :

```
$query = $this->Items->fuse('test');
$query = $this->Items->find('fuse' ['filter' => 'test']);
```

When providing no additional options or configuration, fuzzy search will be applied to all string fields with default options. [Any options accepted by Fuse](https://github.com/loilo/Fuse#options) are available. For instance, to restrict keys and tweak threshold (assuming there's a `name` field in Items data):

```
$query = $this->Items->fuse('test', ['keys' => ['name'], 'threshold' => 0.2]);
$query = $this->Items->find('fuse' ['filter' => 'test', 'fuse' => [keys' => ['name'], 'threshold' => 0.2]]);
```

### Persistent configuration

[](#persistent-configuration)

You can set up your model to always use a given persistent configuration set when using fuse. Is some options are also provided on-the-fly, they will be mixed with persistent ones and override the latter when conflicting.

```
// In the initialize method of the model
$this
  ->addBehavior('Lqdt/CakephpFuse.Fuse')
  ->setSearchableFields(['name'])
  ->setOptions(['threshold' => 0.2]);

// or
$this
  ->addBehavior('Lqdt/CakephpFuse.Fuse')
  ->setOptions([
    'keys' => ['name'],
    'threshold' => 0.2
  ]);

// or
$this->addBehavior('Lqdt/CakephpFuse.Fuse', [
  'keys' => ['name'],
  'threshold' => 0.2
]);
```

### Nested associations

[](#nested-associations)

The search can also be done in nested associations (only `hasOne` or `BelongsTo`) by using a dot separator with **property name** :

```
// Assuming Items belongsTo Owners, with owner as property and name as string field
$query = $this->Items->fuse('test', ['keys' => ['name', 'owner.name']])->contain(['Owners']);

// Assuming Owners also belongsTo Services, with service as property and name as string field
$query = $this->Items->fuse('test', ['keys' => ['name', 'owner.service.name']])->contain(['Owners', 'Owners.Services']);
```

### Autokeys detection

[](#autokeys-detection)

If no keys are provided in options, the model will consider each `string` field as a searchable key. This also works for any contained model in the query :

```
// Will search any string fields in Items, Owners and Services
$query = $this->Items->fuse('test')->contain(['Owners', 'Owners.Services']);
```

API cheatsheet
--------------

[](#api-cheatsheet)

`fuse(string $finder, array $options = [], \Cake\ORM\Query $query = null) : Query`

Schedule the fuzzy search with `finder` keyword(s) on the results of the query and returns the query. If none is provided, the autokeys and default options will be applied only at runtime

`find('fuse', array $options = [])`

Convenient custom finder that relies on `fuse` method. To avoid any conflicts between regular query options and fuse options, expected options must follow this convention : `['filter' => , 'fuse' => [:, ...]]`

`getSearchableFields(): array`

Returns the persistent defined keys for fuzzy search or populates them with autofields if none is set

`setSearchableFields(array $fields = []): self`Sets the persistent defined keys for fuzzy search

`getFuseOptions(): array`

Returns the current persistent options

`setFuseOptions(array $options, bool $replace = false): self`

Sets the persistent options. If keys are conflicting, provided value will override current value. If `replace` is set to true, all options will be replaced

There is some more advanced tools that can be found in behavior code.

CHANGELOG
---------

[](#changelog)

- v1.0.2 : Fix `find('fuse')` documentation
- v1.0.1: Add compatibility for cakePHP ^4.2 (`getTable` deprecation)
- v1.0.0: Initial release

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

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

Every ~94 days

Total

3

Last Release

1813d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

cakephp-pluginfusefuzzy-searchphp7databaseormfilterfuzzyfuse

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/liqueurdetoile-cakephp-fuse/health.svg)

```
[![Health](https://phpackages.com/badges/liqueurdetoile-cakephp-fuse/health.svg)](https://phpackages.com/packages/liqueurdetoile-cakephp-fuse)
```

###  Alternatives

[liqueurdetoile/cakephp-orm-json

Cakephp plugin to provide easy control over JSON type fields in database

1461.1k](/packages/liqueurdetoile-cakephp-orm-json)[friendsofsymfony1/doctrine1

PHP Database ORM for Symfony1. Do NOT use for new projects: please move to a newest Symfony release and Doctrine2

40581.8k](/packages/friendsofsymfony1-doctrine1)[icanboogie/activerecord

ActiveRecord Object-relational mapping

135.0k3](/packages/icanboogie-activerecord)

PHPackages © 2026

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