1. Go to this page and download the library: Download loilo/fuse library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Get an associative array of all options listed above
Fuse::config();
// Merge associative array of options into default config
Fuse::config(['shouldSort' => false]);
// Get single default option
Fuse::config('shouldSort');
// Set single default option
Fuse::config('shouldSort', false);
public function search(mixed $pattern, ?array $options): array
public function setCollection(array $docs, ?\Fuse\Core\FuseIndex $index): void
$fruits = ['apple', 'orange'];
$fuse = new Fuse($fruits);
$fuse->setCollection(['banana', 'pear']);
public static function createIndex(array $keys, array $docs, array $options = []): \Fuse\Core\FuseIndex
$list = [ ... ]; // See the example from the 'Usage' section
$options = [ 'keys' => [ 'title', 'author.firstName' ] ];
// Create the Fuse index
$myIndex = Fuse::createIndex($options['keys'], $list);
// Initialize Fuse with the index
$fuse = new Fuse($list, $options, $myIndex);
public static function parseIndex(array $data, array $options = []): \Fuse\Core\FuseIndex
// (1) When the data is collected
$list = [ ... ]; // See the example from the 'Usage' section
$options = [ 'keys' => [ 'title', 'author.firstName' ] ];
// Create the Fuse index
$myIndex = Fuse::createIndex($options['keys'], $list);
// Serialize and save it
file_put_contents('fuse-index.json', json_encode($myIndex));
// (2) When the search is needed
// Load and deserialize index to an array
$fuseIndex = json_decode(file_get_contents('fuse-index.json'), true);
$myIndex = Fuse::parseIndex($fuseIndex);
// Initialize Fuse with the index
$fuse = new Fuse($list, $options, $myIndex);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.