Search code examples
phplaravelapilumen

Lumen api issue


I've installed Lumen framework, it works but I can't get access to the api. When I just go to the public folder https://example.com/lumen/public/ it shows response correctly: Lumen (5.5.2) (Laravel Components 5.5.*)

Then I've made simple api by this tutorial but can not access to this api https://example.com/lumen/public/api/authors

As a result I have HTTP ERROR 500

Then I've made exactly the same project on my Cloud9 hosting for testing and there I can access to the api page without an issue.

I don't understand why there is an error for Lumen's api request on one of my hostings in fact that projects are the same? What it can be? Is there any special configs for Lumen routing/api e.t.c.?

Any advice will be appreciated!


Solution

  • You need to write .htaccess file on root as below :

     ## enable rewrites
    
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^lumen(.*)/$ /lumen/public/index.php?$1 [QSA,L]
    

    then you can call as below :

    http://example.com/lumen/public/api/authors

    You can also refer below link for more details.

    https://auth0.com/blog/developing-restful-apis-with-lumen/