| Package Data | |
|---|---|
| Maintainer Username: | orkhan | 
| Maintainer Contact: | o@ink.az (Orkhan) | 
| Package Create Date: | 2013-10-18 | 
| Package Last Update: | 2013-10-19 | 
| Language: | PHP | 
| License: | MIT | 
| Last Refreshed: | 2025-10-28 03:02:09 | 
| Package Statistics | |
|---|---|
| Total Downloads: | 23 | 
| Monthly Downloads: | 0 | 
| Daily Downloads: | 0 | 
| Total Stars: | 1 | 
| Total Watchers: | 1 | 
| Total Forks: | 0 | 
| Total Open Issues: | 0 | 
Sphinx Search for Laravel 4 - InkSphinxize
First, you'll need to add the package to the require attribute of your composer.json file:
{
    "require": {
        "ink/ink-sphinxize": "dev-master"
    },
}
Afterwards, run composer update from your command line.
Then, add 'Ink\InkSphinxize\InkSphinxizeServiceProvider', to the list of service providers in app/config/app.php
and add 'InkSphinxizeSearch' => 'Ink\InkSphinxize\Facades\InkSphinxize', to the list of class aliases in app/config/app.php.
From the command line again, run php artisan config:publish ink/ink-sphinxize.
Define a private static property $sphinxize with the definitions:
class Post extends Eloquent
{
	
	use Ink\InkSphinxize\InkSphinxize;
	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'posts';
        	
	/**
	 * InkSphinxize configs
	 *
	 * @var array
	 */
	private static $sphinxize = [
		'index'   => 'posts',
		'pk'      => 'id',
		'perPage' => 15,
	];
}
That's it!
Route::get('/', function()
{
	$perPage = 5; // Override $sphinxize perPage value
	
	$ids = Post::ss('Azerbaijan')
			->ids()
			->skip(5)
			->take($perPage)
			->get();
	// Returns [2, 34, 66, 98, 103, ...]
	
	$records = Post::ss('Azerbaijan')
				->limit(0, $perPage)
				->get();
	// Returns \Illuminate\Database\Eloquent\Collection
	
	$records = Post::ss('Azerbaijan')
				->limit(0, $perPage)
				->with('category')
				->get();
	// Returns \Illuminate\Database\Eloquent\Collection with Eager loading
	
	$records = Post::ss('Azerbaijan')
				->with(array('category', 'tags' => function($query){
					$query->where('name', 'like', '%baku%');
				}))
				->paginate($perPage);
	// Returns \Illuminate\Database\Eloquent\Collection with Eager loading
	
	$paginator = Paginator::make($records->toArray(), count($records->toArray()), $perPage);
	// Paginator
				
	dd($records);
});
Please use Github for bugs, comments, suggestions. Pull requests are preferred!
InkSphinxize was written by Orkhan Maharramli and released under the MIT License. See the LICENSE file for details.
Copyright 2013 Orkhan Maharramli