Initial 2.0 commit
This commit is contained in:
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
0
.travis.yml
Normal file → Executable file
0
.travis.yml
Normal file → Executable file
18
README.md
Normal file → Executable file
18
README.md
Normal file → Executable file
@ -1,28 +1,28 @@
|
|||||||
Laravel 4+ Searchy
|
Laravel Searchy 2
|
||||||
========================================
|
========================================
|
||||||
### Database Searching Made Easy
|
### Database Searching Made Easy
|
||||||
|
|
||||||
Searchy is an easy-to-use Laravel 4+ package that makes running user driven searches on data in your models simple and effective.
|
Searchy is an easy-to-use Laravel Optimized package that makes running user driven searches on data in your models simple and effective.
|
||||||
It uses pseudo fuzzy searching and other weighted mechanics depending on the search driver that you have enabled.
|
It uses pseudo fuzzy searching and other weighted mechanics depending on the search driver that you have enabled.
|
||||||
It requires no other software installed on your server (so a bit slower than dedicated search programs) but can be set up and ready to go in minutes.
|
It requires no other software installed on your server (so can be a little slower than dedicated search programs) but can be set up and ready to go in minutes.
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
Add `"tom-lingham/searchy" : "dev-master"` to your composer.json file under `require`:
|
Add `"tom-lingham/searchy" : "2.0~"` to your composer.json file under `require`:
|
||||||
```
|
```
|
||||||
"require": {
|
"require": {
|
||||||
"laravel/framework": "4.*",
|
"laravel/framework": "4.*",
|
||||||
"tom-lingham/searchy" : "dev-master"
|
"tom-lingham/searchy" : "dev-master"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
Run `composer update` in your terminal to pull the package down into your vendors folder.
|
Run `composer update` in your terminal to pull down the package into your vendors folder.
|
||||||
|
|
||||||
Add the service provider to the `providers` array in Laravel's app/config/app.php file:
|
Add the service provider to the `providers` array in Laravel's app/config/app.php file:
|
||||||
```php
|
```php
|
||||||
'TomLingham\Searchy\SearchyServiceProvider'
|
'TomLingham\Searchy\SearchyServiceProvider'
|
||||||
```
|
```
|
||||||
|
|
||||||
Add the Alias to the `aliases` array in Laravel's app/config/app.php file:
|
Add the Alias to the `aliases` array in Laravel's app/config/app.php file if you want to have quick access to it in your application:
|
||||||
```php
|
```php
|
||||||
'Searchy' => 'TomLingham\Searchy\Facades\Searchy'
|
'Searchy' => 'TomLingham\Searchy\Facades\Searchy'
|
||||||
```
|
```
|
||||||
@ -43,7 +43,7 @@ $users = Searchy::search('users')->fields('name', 'email')->query('John Smith');
|
|||||||
```
|
```
|
||||||
In this case, pass the columns you want to search through to the `fields()` method.
|
In this case, pass the columns you want to search through to the `fields()` method.
|
||||||
|
|
||||||
These examples both return a Laravel DB Query Builder Object, so you will need to chain `get()` to actually return the results in a usable object:
|
These examples both return a Laravel DB Query Builder Object, so you will need to chain `get()` to actually return the results:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$users = Searchy::search('users')->fields('name', 'email')->query('John Smith')->get();
|
$users = Searchy::search('users')->fields('name', 'email')->query('John Smith')->get();
|
||||||
@ -113,7 +113,7 @@ protected $matchers = [
|
|||||||
'TomLingham\Searchy\Matchers\InStringMatcher' => 30,
|
'TomLingham\Searchy\Matchers\InStringMatcher' => 30,
|
||||||
'TomLingham\Searchy\Matchers\TimesInStringMatcher' => 8,
|
'TomLingham\Searchy\Matchers\TimesInStringMatcher' => 8,
|
||||||
];
|
];
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Levenshtein Search Driver (Experimental)
|
#### Levenshtein Search Driver (Experimental)
|
||||||
@ -124,7 +124,7 @@ The Levenshtein Search Driver uses the Levenshetein Distance to calculate the 'd
|
|||||||
protected $matchers = [
|
protected $matchers = [
|
||||||
'TomLingham\Searchy\Matchers\LevenshteinMatcher' => 100
|
'TomLingham\Searchy\Matchers\LevenshteinMatcher' => 100
|
||||||
];
|
];
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Matchers
|
Matchers
|
||||||
|
44
composer.json
Normal file → Executable file
44
composer.json
Normal file → Executable file
@ -1,25 +1,25 @@
|
|||||||
{
|
{
|
||||||
"name": "tom-lingham/searchy",
|
"name": "tom-lingham/searchy",
|
||||||
"description": "Laravel 4 Searchy makes user driven searching easy with fuzzy search, basic string matching and more to come!",
|
"description": "Laravel Searchy makes user driven searching easy with fuzzy search, basic string matching, Levenshtein Distance and more.",
|
||||||
"keywords": ["laravel","search"],
|
"keywords": ["laravel","search","fuzzy"],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Tom Lingham",
|
"name": "Tom Lingham",
|
||||||
"email": "tjlingham@gmail.com"
|
"email": "tjlingham@gmail.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.4.0",
|
"php": ">=5.4.0",
|
||||||
"illuminate/support": "4.2.*"
|
"illuminate/support": "5.*"
|
||||||
},
|
},
|
||||||
"require-dev" :{
|
"require-dev" :{
|
||||||
"phpspec/phpspec": "~2.0"
|
"phpspec/phpspec": "~2.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {
|
"psr-0": {
|
||||||
"TomLingham\\Searchy": "src/"
|
"TomLingham": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimum-stability": "stable"
|
"minimum-stability": "stable"
|
||||||
}
|
}
|
||||||
|
0
phpunit.xml
Normal file → Executable file
0
phpunit.xml
Normal file → Executable file
4
src/TomLingham/Searchy/Facades/Searchy.php
Normal file → Executable file
4
src/TomLingham/Searchy/Facades/Searchy.php
Normal file → Executable file
@ -1,6 +1,5 @@
|
|||||||
<?php namespace TomLingham\Searchy\Facades;
|
<?php namespace TomLingham\Searchy\Facades;
|
||||||
|
|
||||||
use TomLingham\Searchy\SearchyServiceProvider;
|
|
||||||
use Illuminate\Support\Facades\Facade;
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,9 +14,6 @@ class Searchy extends Facade
|
|||||||
*/
|
*/
|
||||||
protected static function getFacadeAccessor()
|
protected static function getFacadeAccessor()
|
||||||
{
|
{
|
||||||
if (!static::$app)
|
|
||||||
static::$app = SearchyServiceProvider::make();
|
|
||||||
|
|
||||||
return 'searchy';
|
return 'searchy';
|
||||||
}
|
}
|
||||||
}
|
}
|
0
src/TomLingham/Searchy/Interfaces/MatcherInterface.php
Normal file → Executable file
0
src/TomLingham/Searchy/Interfaces/MatcherInterface.php
Normal file → Executable file
0
src/TomLingham/Searchy/Interfaces/SearchDriverInterface.php
Normal file → Executable file
0
src/TomLingham/Searchy/Interfaces/SearchDriverInterface.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/AcronymMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/AcronymMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/BaseMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/BaseMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/ConsecutiveCharactersMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/ConsecutiveCharactersMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/ExactMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/ExactMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/InStringMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/InStringMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/LevenshteinMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/LevenshteinMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/StartOfStringMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/StartOfStringMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/StartOfWordsMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/StartOfWordsMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/StudlyCaseMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/StudlyCaseMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/TimesInStringMatcher.php
Normal file → Executable file
0
src/TomLingham/Searchy/Matchers/TimesInStringMatcher.php
Normal file → Executable file
6
src/TomLingham/Searchy/SearchBuilder.php
Normal file → Executable file
6
src/TomLingham/Searchy/SearchBuilder.php
Normal file → Executable file
@ -1,9 +1,9 @@
|
|||||||
<?php namespace TomLingham\Searchy;
|
<?php namespace TomLingham\Searchy;
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Config;
|
use Illuminate\Support\Facades\Config;
|
||||||
use TomLingham\Searchy\SearchDrivers\FuzzySearchDriver;
|
use TomLingham\Searchy\SearchDrivers\FuzzySearchDriver;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property mixed driverName
|
* @property mixed driverName
|
||||||
*/
|
*/
|
||||||
@ -84,12 +84,12 @@ class SearchBuilder {
|
|||||||
if ( $this->driverName ){
|
if ( $this->driverName ){
|
||||||
$driverName = $this->driverName;
|
$driverName = $this->driverName;
|
||||||
} else {
|
} else {
|
||||||
$driverName = \Config::get('searchy::default');
|
$driverName = Config::get('searchy::default');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Gets the details for the selected driver from the configuration file
|
// Gets the details for the selected driver from the configuration file
|
||||||
$driverMap = \Config::get("searchy::drivers.$driverName");
|
$driverMap = Config::get("searchy::drivers.$driverName");
|
||||||
|
|
||||||
|
|
||||||
// Create a new instance of the selected drivers 'class' and pass
|
// Create a new instance of the selected drivers 'class' and pass
|
||||||
|
0
src/TomLingham/Searchy/SearchDrivers/BaseSearchDriver.php
Normal file → Executable file
0
src/TomLingham/Searchy/SearchDrivers/BaseSearchDriver.php
Normal file → Executable file
0
src/TomLingham/Searchy/SearchDrivers/FuzzySearchDriver.php
Normal file → Executable file
0
src/TomLingham/Searchy/SearchDrivers/FuzzySearchDriver.php
Normal file → Executable file
0
src/TomLingham/Searchy/SearchDrivers/LevenshteinSearchDriver.php
Normal file → Executable file
0
src/TomLingham/Searchy/SearchDrivers/LevenshteinSearchDriver.php
Normal file → Executable file
0
src/TomLingham/Searchy/SearchDrivers/SimpleSearchDriver.php
Normal file → Executable file
0
src/TomLingham/Searchy/SearchDrivers/SimpleSearchDriver.php
Normal file → Executable file
0
src/TomLingham/Searchy/SearchyServiceProvider.php
Normal file → Executable file
0
src/TomLingham/Searchy/SearchyServiceProvider.php
Normal file → Executable file
0
src/config/config.php
Normal file → Executable file
0
src/config/config.php
Normal file → Executable file
0
src/res/levenshtein.sql
Normal file → Executable file
0
src/res/levenshtein.sql
Normal file → Executable file
0
tests/.gitkeep
Normal file → Executable file
0
tests/.gitkeep
Normal file → Executable file
Reference in New Issue
Block a user