composer require guzzlehttp/guzzle
use GuzzleHttp\Client;
$this->client = new Client([
"base_uri" => $baseUrl,
"headers" => $headers,
"timeout" => Settings::TIMEOUT_SEC
]);
public function behaviors()
{
return [
[
'class' => 'yii\filters\ContentNegotiator',
'only' => ['view', 'index'], // in a controller
// if in a module, use the following IDs for user actions
// 'only' => ['user/view', 'user/index']
'formats' => [
'application/json' => Response::FORMAT_JSON,
],
'languages' => [
'en',
'de',
],
],
];
}
<?php $form = \yii\widgets\ActiveForm::begin([
'id' => 'my-form-id',
'method' => 'get'
]); ?>
actionIndex()
вместо данных из POST запроса обработать данные из GET-запроса. $model->addError('username', 'Не верный логин пользователя');
return $this->render('login', [
'model' => $model,
]);