Restler always returns 404: Not found

前端 未结 2 1290
长情又很酷
长情又很酷 2020-12-21 00:09

I have installed Restler on my local server to test and make some APIs for my project.

Api requests are handled via http://localhost/myproject/api/.

相关标签:
2条回答
  • 2020-12-21 00:46

    Here is how you can debug and find whats wrong,

    • Remove the namespace in api.php. It is not required and will cause issues.

    • Copy explorer folder to /myproject/api folder and add Resources class as an api class

      $restler->addApiClass('Resources'); //this produces the needed resources.json
      
    • If you are adding User class with a namespace, make sure it defined under that namespace and made available with your include statements or autoloader.

    • You can create /myproject/api/cache folder and make it writable. When you instantiate restler in production mode with cache refresh as shown below, it will create routes.php in cache folder which lists all the routes information

      $restler = new Restler(true,true); //production_mode, refresh
      

    Hope you find whats wrong with the above

    0 讨论(0)
  • 2020-12-21 00:53

    Check to make sure your function is public not private.

    I actually just had the same problem and just spent an hour figuring it out (facepalm).

    0 讨论(0)
提交回复
热议问题