PHP code example of tvip / yii2-extjs-rest

1. Go to this page and download the library: Download tvip/yii2-extjs-rest library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tvip / yii2-extjs-rest example snippets


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",
    },
});


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'],
                ],
            ]
        ]);
    }
}