I am following this tutorial
http://learncooltech.com/yii2-angular-how-to-create-single-page-application-in-minutes/
I got this tutorial to work and now I can see GET /books: list all books page by page;
However, now I want to create some endpoints and in my controller I added a method test but I get a 404. here is my controller
namespace app\controllers;
use yii\rest\ActiveController;
class BookController extends ActiveController
{
public $modelClass = 'app\models\Book';
public function behaviors()
{
return
\yii\helpers\ArrayHelper::merge(parent::behaviors(), [
'corsFilter' => [
'class' => \yii\filters\Cors::className(),
],
]);
}
public function actionTest(){
return json_encode(array("name"=>"John Doe"));
}
}
I have this as my urlRule
'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'showScriptName' => false,
'rules' => [
['class' => 'yii\rest\UrlRule', 'controller' => ['book']],
],
],
and I am doing
http://localhost/events/test
to get to the endpoint
and I get this
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-param" content="_csrf">
<meta name="csrf-token" content="cWdHTlZnWE8uNn5jEDQVHwZXJDcUIykKADUjAgM/Ei4dXn4mOAwNCg==">
<title>Not Found (#404)</title>
<link href="/assets/a7503887/css/bootstrap.css" rel="stylesheet">
<link href="/css/site.css" rel="stylesheet">
</head>
<body>