Render Views from outside the Views folder in Lumen

552 Views Asked by At

i'm writing an API in Lumen 5.3 and i'd like to include APIDoc for my Documentation, im rendering the APIDoc files to app/API/Docs and i'd like to be able to render the index.html from this file whenever the /docs route is hit by a Get request on the browser. How can i achieve this in Lumen?

1

There are 1 best solutions below

0
On

The way i ended up fixing it was i just moved everything over to the public folder under public/docs and then set my apidoc script up in npm so that it'll copy it's files to that directory when i run npm run apidoc

In package.json

"scripts": {
    "apidoc": "apidoc -i app/API/v1/Controllers/ -o public/docs/"
},

Then in my routes file i set up a file_get_contents for the index page of the docs.

return file_get_contents( public_path() . 'docs/index.html');

And it works just fine.