PHP code example of inkime / elasticsearch-query-builder

1. Go to this page and download the library: Download inkime/elasticsearch-query-builder 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/ */

    

inkime / elasticsearch-query-builder example snippets


namespace webapi\es;
use inkime\elasticsearch\ActiveRecord;
use inkime\elasticsearch\Query;
use webapi\services\LogService;

class SdModel extends ActiveRecord
{
    public static $gateway = 'xxx';

    public static $authorization = 'xxx';

    public function logRecord($request, $response)
    {
        // 使用1,记录Log日志
        $logFile = \Yii::getAlias('@runtime/logs/es.log');
        file_put_contents($logFile, var_export($request, true) . PHP_EOL, FILE_APPEND);
        file_put_contents($logFile, var_export($response, true) . PHP_EOL, FILE_APPEND);
        // 使用2,持久化存DB
        (new LogService())->saveSysLog(var_export($request, true));
    }