Laravel Scout is now open for developer testing
Published on by Eric L. Barnes
Laravel Scout is a driver based full-text search for Eloquent that is going to be available when Laravel 5.3 launches.
The driver is not officially released yet, however, the repository is now live and available for those that want to play with more engines.
Taylor said he would be working on docs this week in anticipation of the official 5.3 release and this first release should only be used in testing until it’s officially launched.
For those not familiar with Scout it is an optional package that makes full-text searching simple.
Scout works by implementing a “Searchable” trait with your existing models. Then it’s just a matter of syncing the data with the search service like this:
php artisan scout:import App\\Post
After that you can search your models with:
Post::search('Alice')->get();
You can even paginate:
Post::search('Alice')->paginate()
And it even includes simple where clauses:
Post::search(‘Alice’)—>where('acount_id', '>', 1)->paginate()
The repository has already had a few pull requests for adding additional search engines and Taylor is recommending developers create their own packages like what is being done with Laravel Notifications.
Once 5.3 is official the documentation for Scout will be available and it’ll be ready for all.
Eric is the creator of Laravel News and has been covering Laravel since 2012.