I am trying to access a REST endpoint GET v1/applications
however it does not seem to hit the actionView
controller method in the associated controller. I have some dummy code and an XDebug breakpoint set in there, and it’s as if the controller action is skipped entirely before the JSON is returned. Is there a way to get them to hit the controller actions, or will I have to resort back to using a web URL manager and returning JSON instead of rendering a view?
Here is my urlManager config:
'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'showScriptName' => false,
'rules' => [
"" => "site/index",
['class' => 'yii\rest\UrlRule', 'controller' => ['v1/user', 'v1/application', 'v1/flag', 'v1/role']],
],
],
Here is my controller:
<?php
namespace app\api\v1\controllers;
use app\api\common\controllers\ApplicationController as CommonApplicationController;
class ApplicationController extends CommonApplicationController
{
public $modelClass = ‘app\api\v1\models\Application’;
public function actionCreate()
{
}
public function actionDelete($uid)
{
}
public function actionIndex()
{
}
public function actionView($uid)
{
$f = 8;
}
public function actionUpdate($uid)
{
}
}