REST API ActiveController support for input parameters extjs and serialize response. Enable in extjs store remoteSort, remoteFilter and autoSync in viewModel.
Ext.define('tvip.proxy.YiiRestProxy', {
extend: 'Ext.data.proxy.Rest',
alias: 'proxy.yiirest',
type: 'rest',
reader: {
type: 'json',
rootProperty: 'data',
},
writer: {
type: 'json'
},
headers: {
"Accept": "application/json",
},
});
composer require tvip/yii2-extjs-rest
Example controller
<?php
namespace app\modules\api\components;
use Yii;
use yii\helpers\ArrayHelper;
use tvip\ExtJsRest\ActiveController;
class Controller extends ActiveController
{
/**
* @inheritdoc
*/
public function behaviors()
{
return ArrayHelper::merge(parent::behaviors(),[
'corsFilter' => [
'class' => \yii\filters\Cors::className(),
'cors' => [
'Origin' => ['*'],
'Access-Control-Request-Headers' => ['*'],
'Access-Control-Request-Method' => ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'],
],
]
]);
}
}