1. Go to this page and download the library: Download lingxi/ali-opensearch-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Models;
use Lingxi\AliOpenSearch\Searchable;
class User extends Model
{
use Searchable;
/**
* Get the index name for the model.
*
* @return string
*/
public function searchableAs()
{
return 'user';
}
public function toSearchableDocCallbacks($actions = ['update', 'delete'])
{
throw new Exception('这个应用不需要手动维护数据');
}
public function getSearchableFields()
{
return 'id';
}
}