rest - How do I solve this Yii2 RESTful Web Service API routing error? -


I'm trying to implement the Yii2 Restart Web Service API described in the guide. I'm trying to use an advanced app template. The problem is that when I try to use the service, I get 404 errors. I wanted to start trying something easy, so I was just going to use a country table and affiliate active class to see it, here is the code:

This frontend / configure / The component is in the component configuration .php:

  'urlManager' = & gt; ['EnablePrettyUrl' = & gt; True, 'enableStrictParsing' = & gt; True, 'showScriptName' = & gt; Wrong, 'rule' = & gt; [['Class' = & gt; 'Yii \ rest \ UrlRule', 'Controller' = & gt; 'Country'],],], 'request' = & gt; ['Parser' = & gt; ['Application / JS' = & gt; 'Yii \ web \ jsonparser',]]  

This is the code in Frontend / Controllers / Country Controller. FTP:

  Namespace Controller; Use Yii \ rest \ ActiveController; Square Country Controller Extends ActiveController {public $ model class = 'normal' model \ country '; }  

Countries like all my ActiveRecord models are in normal / model.

I used the following to try:

  curl-eh "Accept: Application / Jason" "http: //myfrontendapp.loc/country " 

This is the output I received:

  HTTP / 1.1 404 not found Date: Fri, 31 October 2014 22:46:50 GMT Server: Apache Content-Length: 205 Content-Type: Text / html; Charset = iso-8859-1 & lt ;! DOCTYPE HTML PUBLIC "- // IETF // DTD HTML 2.0 / N" & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; 404 Not Found & lt; / Heading & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; H1 & gt; Did not get & lt; / H1> & Lt; P & gt; The requested URL / country was not found on this server. & Lt; / P & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

I have spent many hours on this. I have adjusted the settings, have read the documentation, and many more without any success. If someone can see what the problem is, please tell me, thank you!

You are affected by the behavior of the default UrlRule class pluralization: mango Consistent with the relation of comfort, there is enough to turn a controller named country in the plural path of the name / country . go to http: //myfrontendapp.loc/countries and it will most likely work fine. It also goes for all other routes created by the UrlRule, e.g. GET / country / 12345

Or, if you want to disable this behavior, you can set the $ Multiply of URLRule to false . Check for more information


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -