Download the PHP package brilliance/algolia-sync without Composer

On this page you can find all versions of the php package brilliance/algolia-sync. 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 algolia-sync

Algolia Sync plugin for Craft CMS

Syncing elements with Algolia using their API

Requirements

This plugin requires Craft CMS 3.4.18 or later.

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

    cd /path/to/project
  2. Then tell Composer to load the plugin:

    composer require brilliancenw/craft-algolia-sync
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Algolia Sync.

  4. In your .env file, load the Algolia Application ID, the Search Only API Key and the Admin API Key.

  5. Select which element types should be synced with Algolia. If the default index names do not work for you, enter enter the names of the indexes you want to sync. These values can be set per environment.

Algolia Sync Information

When any record is added, edited or deleted, the Algolia Sync plugin will be alerted. If that element type is configured to be synced, it will package up these values and ship them off to the associated Algolia Index.

Prior to sending the data off, there is an event that is announaced - you can intercept the data and make changes to whatever is put in the Algolia index. You can add, edit or delete any of the data in that record (without actually changing the data in Craft.)

Here's an example of updating the value of the field with handle myCustomFieldHandle:

    Event::on(
        \brilliance\algoliasync\services\AlgoliaSyncService::class,
        \brilliance\algoliasync\services\AlgoliaSyncService::EVENT_BEFORE_ALGOLIA_SYNC,
        function (\brilliance\algoliasync\events\beforeAlgoliaSyncEvent $event) {
            $event->recordUpdate['attributes']['myCustomFieldHandle'] = "Updating the content of this field";

            // to prevent a record from being added, edited or deleted in Algolia
            // set the following flag.
            // $event->recordUpdate['processAlgoliaSync'] = false;

            }
    );

Some specific Field Types

Asset Fields

When a record has an Asset field, if there is only one asset added, it will be a string of the URL of the asset. If there are more than one assets added to that field in that record, it will be an array of the URLs of the asset. This makes featured images very useful when configured in Algolia to be the image of the record.

Date Fields

For every date field, three fields are sent to Algolia.

  1. The unix timestamp of the date
  2. The "friendly" view of the date (in American format m/d/Y)
  3. the unix timestamp of the midnight of the date. This is helpful for searching for ranges related to dates

Category / User / Entry fields

For each of these fields, the value is sent as the title of the record as an Array. Additionally, an array of the Element IDs for each of these records is sent. For example: if the record contains a Category field with the name "Genre", and I have 3 categories selected, the data sent will be

Genre ['title 1', 'title 2', 'title 3'] AND GenreIds [1,2,3]

This can be used for some very complex JS work on the display of your search results in instantsearch.

Algolia Sync Roadmap

Some things to do, and ideas for potential features:

Pull Requests, Feature Requests and Bug Reports are welcome - please submit to the Git repository: https://github.com/brilliancenw/craft-algolia-sync

Brought to you by Brilliance https://www.brilliancenw.com/


All versions of algolia-sync with dependencies

PHP Build Version
Package Version
Requires craftcms/cms Version ^5
algolia/algoliasearch-client-php Version ^4
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 brilliance/algolia-sync contains the following files

Loading the files please wait ....