PHP code example of hoaaah / yii2-rest-api-template
1. Go to this page and download the library: Download hoaaah/yii2-rest-api-template 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/ */
use app\helpers\BehaviorsFromParamsHelper;
use yii\rest\ActiveController;
class PostController extends ActiveController
{
public $modelClass = 'app\models\Post';
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors = BehaviorsFromParamsHelper::behaviors($behaviors);
// if you need other behaviors method use like this
// $behaviors['otherMethods'] = $value;
return $behaviors;
}
}
public $tokenExpiration = 60 * 24 * 365; // in seconds