Download the PHP package james2doyle/laravel-scout-sonic without Composer

On this page you can find all versions of the php package james2doyle/laravel-scout-sonic. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-scout-sonic

Laravel Scout Sonic Driver

Search Eloquent Models using Sonic indexes.

  1. Implementation
  2. Installation
  3. Usage

Implementation

When implementing the toSearchableArray method, you need to provide an array that will be coerced into a string (the engine just joins with a ' ') as Sonic can only index strings. So you need to provide a "stringified" (index string) version of your model. The default toArray works but it is probably too much noise for reasonable usage.

Here is an example of the string I used when I was developing this Engine:

For me, this builds a nice string for search that can match on a "name". In my application, the concept of "name" is either the User display name or first/last name.


If the locale is known, you can also create the getSonicLocale() method on your model, which returns the locale. It will then get passed to the Sonic PUSH calls:

Installation

If you haven't already you should install Laravel Scout to your project and apply the Laravel\Scout\Searchable trait to any Eloquent models you would like to make searchable.

Install this package via Composer

composer require james2doyle/laravel-scout-sonic

Note: if you have Laravel >= 5.5 you can skip this step because of Package Auto-Discovery.

Next add the ServiceProvider to the Package Service Providers in config/app.php

Append the default configuration to config/scout.php

Set SCOUT_DRIVER=sonic in your .env file

In addition there is no need to use the php artisan scout:import command.

Usage

Simply call the search() method on your Searchable models:

$users = App\User::search('bro')->get();

Simple constraints can be applied using the where() builder method:

$users = App\User::search('bro')->where('active', 1)->get();

Note: Sonic does not support the concept of "where", so the where is applied at the collection level not the query!

Pagination

Sonic cannot support real pagination because Sonic does not return proper paging or total information. It simply returns all the results for a given query.

There is a naive implementation of pagination in place but it probably isn't perfect as it doesn't take into account the "where" filter.

For more usage information see the Laravel Scout Documentation.


All versions of laravel-scout-sonic with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
laravel/scout Version ^7.1|^8.0
ppshobi/psonic Version ^1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package james2doyle/laravel-scout-sonic contains the following files

Loading the files please wait ....