M
M
Maxim Grechushnikov2015-06-30 13:57:30
Yii
Maxim Grechushnikov, 2015-06-30 13:57:30

Yii2, REST: I don't understand what I'm doing wrong. Why 404?

Good time. Prompt by yii\rest

use yii\rest\ActiveController;
class CountryController extends ActiveController{
    public $modelClass = 'app\models\Country';
}

config
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                [
                    'class' => 'yii\rest\UrlRule',
                    'controller' => 'country',
                ]
            ],
        ],

pgg.loc/v1/country displays the entire list of countries
pgg.loc/v1/country/1 error 404
although https://github.com/yiisoft/yii2/blob/master/framew... says that it should be generated automatically, relative to the controller

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Grechushnikov, 2015-06-30
@maxyc_webber

pgg.loc/v1/countr y
pgg.loc/v1/countries / 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question