01/06
2016
dev-master
9999999-devSimple autocomplete functionality
MIT
The Development Requires
by Richard Crosby
Simple autocomplete functionality
A useful package for efficient autocomplete functionality., (*1)
Using composer:, (*2)
composer require phparmory/autocomplete
, (*3)
<?php use Armory\Autocomplete\Autocomplete; use Armory\Autocomplete\Repositories\ArrayRepository; $autocomplete = new Autocomplete(new ArrayRepository); $autocomplete->index(1, "King Kong", 'movies'); // Indexes 'King Kong' against ID 1 in the 'movies' namespace $autocomplete->index(2, "King's Speech", 'movies'); // Indexes "King's speech" against ID 2 in the 'movies' namespace $autocomplete->find('King', 'movies'); // Returns [1, 2]; $autocomplete->find("King's", 'movies'); // Returns [2];
Autocomplete comes with an array and a Redis repository. An example using Redis:, (*4)
<?php use Armory\Autocomplete\Autocomplete; use Armory\Autocomplete\Repositories\RedisRepository; use Predis\Client; $autocomplete = new Autocomplete(new RedisRepository(new Client)); $autocomplete->index(1, 'Spiderman', 'movies'); $autocomplete->find('spider', 'movies'); // Returns [1]
Simple autocomplete functionality
MIT