You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.4 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. Laravel 4+ Searchy - Searching Made Easy
  2. ========================================
  3. Searchy is an easy-to-use Laravel 4+ package that makes running user driven searches on data in your models easy and effective.
  4. It requires no other software installed on your server (so a bit slower) but can be setup and ready to go in minutes.
  5. Installation
  6. ----------------------------------------
  7. Add the service provider to the `providers` array in Laravel's app/config/app.php file:
  8. ```
  9. 'TomLingham\Searchy\SearchyServiceProvider'
  10. ```
  11. Add the Alias to the `aliases` array in Laravel's app/config/app.php file:
  12. ```
  13. 'Searchy' => 'TomLingham\Searchy\SearchBuilder'
  14. ```
  15. Usage
  16. ----------------------------------------
  17. To use Searchy, you can take advantage of magic methods.
  18. If you are searching the name column/field of users in a `users` table you would, for example run:
  19. ```
  20. $users = Searchy::users('name')->query('John Smith');
  21. ```
  22. you can also write this as:
  23. ```
  24. $users = Searchy::search('users')->query('John Smith');
  25. ```
  26. These example both return a Laravel DB Query Builder Object, so you will need to chain `get()` to actually return the results in a usable object:
  27. ```
  28. $users = Searchy::search('users')->query('John Smith')->get();
  29. ```
  30. Configuration
  31. ----------------------------------------
  32. You can publish the configuration file to override the settings by running `php artisan config:publish tom-lingham/searchy`
  33. You can set the default driver to use for ssearches in the configuration file. Your options (At this stage) are: `fuzzy`, `simple` and `levenshtein`.
  34. You can also override these methods using the following syntax when running a search:
  35. ```
  36. Searchy::driver('fuzzy')->users('name')->query('Bat Man')->get();
  37. ```
  38. Drivers
  39. ----------------------------------------
  40. Searchy takes advantage of 'Drivers' to handle matching various conditions of the fields you specify.
  41. Drivers are simply a specified group of 'Matchers' which match strings based on different conditions.
  42. Currently there are only three drivers: Simple, Fuzzy and Levenshtein (Experimental).
  43. ### Road Map
  44. So, the intention is to (in the future):
  45. 1. Remove Searchy's dependancy on Laravel
  46. 2. Include more drivers for more advanced searching (Including file searching, indexing and more)
  47. 3. Implement an AJAX friendly interface for searching models and implementing autosuggestion features on the front end
  48. 4. Speed up search performance