Answer the question
In order to leave comments, you need to log in
How to configure yii2 api correctly?
<?php
namespace api\modules\v1\controllers;
use yii;
use yii\rest\ActiveController;
/**
* Default controller for the `v1` module
*/
class ActionsController extends ActiveController
{
public $modelClass = 'api\modules\v1\models\Test';
public function actionHistory()
{
$request = Yii::$app->request;
if ($request->get('format') == 'json')
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
}
public function actionHistorySum()
{
$request = Yii::$app->request;
if ($request->get('format') == 'json')
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question