evstevemd
(Stefano Mtangoo)
July 10, 2014, 3:44pm
1
Hi,
I’m testing REST API with Yii2 and I have hit a wall.
Here is what I have done according to the Guide
Created Controller
<?php
namespace app\controllers;
class ApiController extends \yii\rest\ActiveController
{
public $modelClass = 'Category'; //my Model inheriting from AR
}
Added to URL manager as said
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => true,
'rules' => [
['class' => 'yii\rest\UrlRule', 'controller' => 'api'],
],
],
Now Each time I try to get Rest API via http://localhost/basic/web/api/ it throws 404 not found.
As a matter of fact it have messed up my codes and even home page cannot be found.
What am I doing wrong?
Also any in depth
evstevemd
(Stefano Mtangoo)
July 11, 2014, 6:23am
2
It happened to be problem in Apache configurations and the enableStrictParsing option.
Changed config and disabled the option and it works fine.
Any implication in rest for disabling enableStrictParsing option?
ahmed201
(Rifajas)
July 12, 2014, 5:50am
3
change
public $modelClass = 'Category'; //my Model inheriting from AR
to
public $modelClass = 'app\models\Category'; //my Model inheriting from AR
Hi,
I’m testing REST API with Yii2 and I have hit a wall.
Here is what I have done according to the Guide
Created Controller
<?php
namespace app\controllers;
class ApiController extends \yii\rest\ActiveController
{
public $modelClass = 'Category'; //my Model inheriting from AR
}
Added to URL manager as said
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => true,
'rules' => [
['class' => 'yii\rest\UrlRule', 'controller' => 'api'],
],
],
Now Each time I try to get Rest API via http://localhost/basic/web/api/ it throws 404 not found.
As a matter of fact it have messed up my codes and even home page cannot be found.
What am I doing wrong?
Also any in depth
evstevemd
(Stefano Mtangoo)
July 12, 2014, 7:06pm
4
thanks.
I had that already and forgot to update.