当我尝试搜索数据时,我在控制台中出现此错误
PHP Notice 'yii\base\ErrorException' with message 'Use of undefined constant CURLOPT_USERAGENT - assumed 'CURLOPT_USERAGENT'' in /var/www/megamart/vendor/yiisoft/yii2-elasticsearch/Connection.php:320
我不明白这是什么问题 在这里我的控制和模型 配置文件:
'elasticsearch' => [
'class' => 'yii\elasticsearch\Connection',
'nodes' => [
['http_address' => '127.0.0.1:9200'],
],
],
Contorller档案:
<?php
namespace frontend\controllers;
use frontend\models\elastic\User;
use yii\web\Controller;
use Yii;
use yii\helpers\VarDumper;
class ElasticController extends Controller{
public function actionTest(){
if(Yii::$app->request->isAjax){
$params = $_POST['q'];
$query = User::find()->where(['username' => 'admin'])->one();
VarDumper::dump($query,6,1);
}
}
}
模型文件:
<?php
namespace frontend\models\elastic;
class User extends \yii\elasticsearch\ActiveRecord
{
public function attributes()
{
return ['id', 'username', 'address'];
}
}
答案 0 :(得分:0)
通过安装此
解决sudo apt-get install php5-curl