PHP code example of xihrni / yii2-restful-actions

1. Go to this page and download the library: Download xihrni/yii2-restful-actions 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/ */

    

xihrni / yii2-restful-actions example snippets




namespace app\controllers;

class ArticleController extends \yii\rest\ActiveController
{
    public $modelClass = 'app\models\Article';


    public function actions()
    {
        return array_merge(parent::actions(), [
            'index' => [
                'class' => 'xihrni\yii2\restful\actions\IndexAction',
                'modelClass' => $this->modelClass,
            ],
            'view' => [
                'class' => 'xihrni\yii2\restful\actions\ViewAction',
                'modelClass' => $this->modelClass,
            ],
            'create' => [
                'class' => 'xihrni\yii2\restful\actions\CreateAction',
                'modelClass' => $this->modelClass,
            ],
            'update' => [
                'class' => 'xihrni\yii2\restful\actions\UpdateAction',
                'modelClass' => $this->modelClass,
            ],
            'delete' => [
                'class' => 'xihrni\yii2\restful\actions\DeleteAction',
                'modelClass' => $this->modelClass,
            ],
            'status' => [
                'class' => 'xihrni\yii2\restful\actions\StatusAction',
                'modelClass' => $this->modelClass,
            ],
        ]);
    }
}