Download the PHP package rias/craft-scout without Composer

On this page you can find all versions of the php package rias/craft-scout. 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 craft-scout

Scout for Craft CMS

Craft Scout provides a simple solution for adding full-text search to your entries. Scout will automatically keep your search indices in sync with your entries.

Scout

Requirements

This plugin requires Craft CMS 4.x or later and PHP 8.0.2 or later.

Installation

Open your terminal and go to your Craft project:

Setup

To define your indices, copy the scout.php file to your config folder.

Example Index Configuration

->elementType(string $class)

The element type that this index contains, by default Scout uses craft\elements\Entry::class

Craft's default element type classes are:

->criteria(callable $query)

This function accepts an ElementQuery and should also return an ElementQuery

->transformer(callable|string|array|TransformerAbstract $transformer)

The transformer that should be used to define the data that should be sent to Algolia for each element. If you don’t set this, the default transformer will be used, which includes all of the element’s direct attribute values, but no custom field values.

Your custom transformer class would look something like this:

->splitElementsOn(array $keys)

For long documents it is advised to divide the element into multiple rows to keep each row within row data size. This can be done using splitElementsOn().

Make sure to return an array in your transformer for these keys.

Important - distinctID (available after indexing) must be set up as an attribute for faceting for deletion of objects to work when using splitElementsOn.

->indexSettings(IndexSettings $settings)

You can use this to define index settings that get synced when you call the ./craft scout/settings/update console command. This way you can keep your index settings in source control. The IndexSettings object provides autocompletion for all Algolia's settings

[!NOTE]
Note that settings are not synced automatically, but only when the ./craft scout/settings/update console command is run.

Replicas

Replicas can be created with the replicas function on IndexSettings. To configure replicas, include them in the indices array and set their replicaIndex to true so that they are not included in any syncing operations.

Replica indices can have their configuration updated using the ./craft scout/settings/update console command.

Twig variables

You can access the Algolia settings set in your config file through the following Twig variables.

Console commands

Scout provides two easy console commands for managing your indices.

Importing

To import one or all indices you can run the following console command

The indexName argument is not required, all your mappings will be imported when you omit it.

Flushing/Clearing

Clearing an index is as easy as running a command in your console.

As with the import command, indexName is not required.

When flushing, Scout will ask you to confirm that you really want to clear all the data in your index. You can bypass the confirmation by appending a --force flag.

Refreshing

Does a flush/clear first and then imports the index again.

Skipping an Element

You can omit an element from being indexed by returning an empty array from the transform method:

Events

ShouldBeSearchableEvent

This event allows you to customize which elements or element types get checked on save (or more specifically, every time the SearchableBehaviour is triggered).

The event has a properties:

An example use-case for this would be to check the type of the element that's being saved and settings shouldBeSearchable to false when it's a Matrix block.

AfterIndexImport

This event runs at the end of the ImportIndex job, when every item has been processed.

The event has one property:

An example use-case for this would be to keep a log or dateLastImported if you're running imports on a schedule.


Upgrading from 1.x

The configuration has changed from how Scout v1 did its configuration. Please see the setup section below on how to configure Scout.

The following changes are the most notable:


Brought to you by Studio Espresso and Rias


All versions of craft-scout with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2.0
craftcms/cms Version ^5.0.0-beta.1
algolia/algoliasearch-client-php Version ^2.3|^3.0
league/fractal Version ^0.20
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 rias/craft-scout contains the following files

Loading the files please wait ....