dev-master
9999999-devAlgolia plugin for CakePHP
The Requires
The Development Requires
Algolia plugin for CakePHP
You can install this plugin into your CakePHP application using composer., (*1)
The recommended way to install composer packages is:, (*2)
composer require be-mohand/cakephp-algolia
In your configuration file (for instance app_local.php), add the Algolia key configuration:, (*3)
<?php return [ 'Algolia' => [ 'appId' => 'xxxx', 'apiKey' => [ 'backend' => 'xxxxxxxxxxxx', 'search' => 'xxxxxxxxxxxx', ], 'index' => 'your_index_name', ] ];
You can create your Algolia account at at https://www.algolia.com., (*4)
Load the Algolia.Algolia behavior in the Table you want to index and add a virtual field in the corresponding entity:, (*5)
protected $_virtual = ['objectID']; public function _getObjectID() { return $this->id; }
Before starting to use the Algolia powerful search engine, you have to sync your data with Algolia database., (*6)
For the purpose, you can use the ImportToAlgoliaShell like this:, (*7)
bin/cake Algolia.ImportToAlgolia --url your_public_url
your_public_url should point to a json file. You can create this json file on the fly with an action like this:, (*8)
Warning: an objectID key is required. Use the primary key, (*9)
Algolia provides an out of box solution for building a search engine. It is named instantsearch.js., (*10)
Start to load the needed js and css files in your template:, (*11)
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/instantsearch.js/1/instantsearch.min.css" /> <script src="//cdn.jsdelivr.net/instantsearch.js/1/instantsearch.min.js"></script>
You need a dummy action with a template where Algolia files are loaded. You can use an example of a working template in Algolia/src/Template/example.ctp., (*12)
When the DebugKit is loaded, we have this error:
toolbar.js:62 Refused to get unsafe header "X-DEBUGKIT-ID"
, (*13)
The starting point of the plugin is the excellent article from startutorial., (*14)
Thanks to the author., (*15)
Algolia plugin for CakePHP