veo/extrest

REST API for Sencha ExtJS 6

Installs: 16

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

dev-master 2019-05-23 22:48 UTC

This package is auto-updated.

Last update: 2022-07-24 05:45:53 UTC


README

REST API ActiveController support for input parameters extjs and serialize response. Enable in extjs store remoteSort, remoteFilter and autoSync in viewModel.

EXAMPLE PROXY CLASS EXTJS

Ext.define('Veobu.proxy.YiiRestProxy', {
    extend: 'Ext.data.proxy.Rest',
    alias: 'proxy.yiirest',

    type: 'rest',

    reader: {
        type: 'json',
        rootProperty: 'data',
    },

    writer: {
        type: 'json'
    },

    headers: {
        "Accept": "application/json",
    },
});

INSTALLATION

composer require Veobu/yii2-extjs-rest

USE

Example controller

<?php
namespace app\modules\api\components;

use Yii;
use yii\helpers\ArrayHelper;
use Veobu\ExtRest\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'],
                ],
            ]
        ]);
    }
}