Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhuzixian520/yii2-meilisearch
MeiliSearch Extension For Yii2 Framework
https://github.com/zhuzixian520/yii2-meilisearch
meilisearch php search yii2
Last synced: 30 days ago
JSON representation
MeiliSearch Extension For Yii2 Framework
- Host: GitHub
- URL: https://github.com/zhuzixian520/yii2-meilisearch
- Owner: zhuzixian520
- License: mit
- Created: 2022-02-10T08:05:30.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-02-21T14:59:27.000Z (almost 3 years ago)
- Last Synced: 2024-10-30T01:51:37.071Z (about 1 month ago)
- Topics: meilisearch, php, search, yii2
- Language: PHP
- Homepage:
- Size: 229 KB
- Stars: 118
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-yii2 - zhuzixian520/yii2-meilisearch
- awesome-meilisearch - Yii2 - Yii2 framework extension (Integrations / Community Integrations)
README
[![Latest Stable Version](http://poser.pugx.org/zhuzixian520/yii2-meilisearch/v)](https://packagist.org/packages/zhuzixian520/yii2-meilisearch) [![Total Downloads](http://poser.pugx.org/zhuzixian520/yii2-meilisearch/downloads)](https://packagist.org/packages/zhuzixian520/yii2-meilisearch) [![Latest Unstable Version](http://poser.pugx.org/zhuzixian520/yii2-meilisearch/v/unstable)](https://packagist.org/packages/zhuzixian520/yii2-meilisearch) [![License](http://poser.pugx.org/zhuzixian520/yii2-meilisearch/license)](https://packagist.org/packages/zhuzixian520/yii2-meilisearch) [![PHP Version Require](http://poser.pugx.org/zhuzixian520/yii2-meilisearch/require/php)](https://packagist.org/packages/zhuzixian520/yii2-meilisearch)
[![Dependents](http://poser.pugx.org/zhuzixian520/yii2-meilisearch/dependents)](https://packagist.org/packages/zhuzixian520/yii2-meilisearch)
[![Suggesters](http://poser.pugx.org/zhuzixian520/yii2-meilisearch/suggesters)](https://packagist.org/packages/zhuzixian520/yii2-meilisearch)## English | [简体中文](./README.zh-CN.md) | [繁體中文](./README.zh-TW.md)
This extension provides the MeiliSearch integration for the Yii framework 2.0.
## Installation
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
composer require zhuzixian520/yii2-meilisearch
```or add
```
"zhuzixian520/yii2-meilisearch": "^1.0"
```to the require section of your `composer.json` file.
Usage
-----Once the extension is installed, simply use it in your code by :
```php
return [
'components' => [
'meilisearch' => [
'class' => zhuzixian520\meilisearch\Connection::class,
'hostname' => 'localhost',
'port' => 7700,
//'apiKey' => 'your_master_key',
//'useSSL' => false,
],
],
];
```### Work with this component
```php
$ms = \Yii::$app->meilisearch;// Set API keys From your master Key
$ms->apiKey = 'xxxx';$msc = $ms->createCommand();
//The health check endpoint enables you to periodically test the health of your Meilisearch instance
$msc->health;
```### Indexes
```php
//$res = $msc->allIndexes;
//$res = $msc->createIndex('movies', 'id');
//$res = $msc->updateIndex('movies', 'id');
//$res = $msc->deleteIndex('movies');
$msci = $msc->index('movies');
//$res = $msci->info;
//$res = $msci->update('id');
//$res = $msci->delete();
```### Documents
```php
$res = $msci->getDocument(25684);
$res = $msci->getDocuments(['offset' => 0, 'limit' => 2, 'attributesToRetrieve' => '*']);
/*$file_name = Yii::getAlias('@app/runtime/') . 'movies.json';
$movies_json = file_get_contents($file_name);
$movies = json_decode($movies_json, true);
$res = $msci->addDocuments($movies,'id');*/
//$res = $msci->updateDocuments($movies,'id');
//$res = $msci->deleteAllDocuments();
//$res = $msci->deleteDocument(100);
//$res = $msci->deleteDocuments([10001, 100017]);
```### Search
```php
$res = $meilisearch->createCommand()->index('movies')->search(['q' => 'saw', 'limit' => 2,]);
var_dump($res);
```### Task
```php
$res = $msc->tasks;
$res = $msc->getTask(4);
$res = $msci->getTasks();
$res = $msci->getTask(8);
```### Keys
```php
//$res = $msc->keys;
//$res = $msc->getKey('9bFPJSxkc0e7939d743e110b354fe3625876cfec14efb4301bf195f6aed4a57f1d9004fa');
/*$res = $msc->createKey([
'description' => 'Add documents: Products API key',
'actions' => ['documents.add'],
'indexes' => ['products'],
'expiresAt' => '2042-04-02T00:42:42Z',
]);*/
/*$res = $msc->updateKey('yKEcAaQX547e46c7d8eaa1224f6a5196c5c7a13f47932cbeb1ba06db962b379cb0ef19e4', [
'description' => 'Add documents: Products API key',
'actions' => ['documents.add'],
'indexes' => ['products'],
'expiresAt' => '2043-04-02T00:42:42Z',
]);*/
//$res = $msc->deleteKey('qAZlXnA191d328ea51fb26b822fecc556c38c0a3af1caa95962ede60a0155381a39a3a36');
```### Settings
```php
$res = $msci->settings;
/*$res = $msci->updateSettings([
'displayedAttributes' => ['*'],
'distinctAttribute' => null,
'filterableAttributes' => [],
'rankingRules' => [
'words',
'typo',
'proximity',
'attribute',
'sort',
'exactness',
'release_date:desc',
'rank:desc'
],
'searchableAttributes' => ['*'],
'sortableAttributes' => [],
'stopWords' => [
'the',
'a',
'an'
],
'synonyms' => [
'wolverine' => ['xmen', 'logan'],
'logan' => ['wolverine']
]
]);*/
//$res = $msci->resetSettings();
//$res = $msci->displayedAttrs;
//$res = $msci->updateDisplayedAttrs(['*']);
//$res = $msci->resetDisplayedAttrs();
/*$res = $msci->distinctAttr;
$res = $msci->updateDistinctAttr('id');
$res = $msci->resetDistinctAttr();
$res = $msci->filterableAttrs;
$res = $msci->updateFilterableAttrs([]);
$res = $msci->resetFilterableAttrs();
$res = $msci->rankingRules;
$res = $msci->updateRankingRules([
'words',
'typo',
'proximity',
'attribute',
'sort',
'exactness',
'release_date:desc',
'rank:desc'
]);
$res = $msci->resetRankingRules();
$res = $msci->searchableAttrs;
$res = $msci->updateSearchableAttrs(['*']);
$res = $msci->resetSearchableAttrs();
$res = $msci->sortableAttrs;
$res = $msci->updateSortableAttrs([]);
$res = $msci->resetSortableAttrs();
$res = $msci->stopWords;
$res = $msci->updateStopWords([
'the',
'a',
'an'
]);
$res = $msci->resetStopWords();
$res = $msci->synonyms;
$res = $msci->updateSynonyms([
'wolverine' => ['xmen', 'logan'],
'logan' => ['wolverine']
]);
$res = $msci->resetSynonyms();*/
```### Stats
```php
//$res = $msc->stats;
//$res = $msci->stats;
```
### Health
```php
$msc->health;
```
### Version
```php
$msc->version;
```
### Dumps
```php
$res = $msc->createDump();
//$res = $msc->getDumpStatus('20220211-145911299');
var_dump($res);
```## Contact Us
>Email:[email protected]## Sponsorship and donation: