Routing
Routing
With resource and controller classes ready, you can access the resources using the URL like http://localhost/index.php?r=user/create
, similar to what you can do with normal Web applications.
In practice, you usually want to enable pretty URLs and take advantage of HTTP verbs. For example, a request POST /users
would mean accessing the user/create
action. This can be done easily by configuring the urlManager
application component in the application configuration like the following:
'urlManager' => [ 'enablePrettyUrl' => true, 'enableStrictParsing' => true, 'showScriptName' => false, 'rules' => [ ['class' => 'yii\rest\UrlRule', 'controller' => 'user'], ], ]
Compared to the URL management for Web applications, the main new thing above