【问题标题】:Render Views from outside the Views folder in Lumen从 Lumen 中的 Views 文件夹外部渲染视图
【发布时间】:2016-11-03 11:13:18
【问题描述】:

我正在 Lumen 5.3 中编写 API,我想在我的文档中包含 APIDoc,我将 APIDoc 文件渲染到 app/API/Docs,我希望能够渲染索引。每当浏览器上的 Get 请求命中 /docs 路由时,都从此文件中获取 index.html。我如何在 Lumen 中实现这一点?

【问题讨论】:

    标签: laravel-5 lumen api-doc fastroute


    【解决方案1】:

    我最终修复它的方式是将所有内容移至 public/docs 下的公共文件夹,然后在 npm 中设置我的 apidoc 脚本,以便在我运行 npm run apidoc 时将其文件复制到该目录

    在 package.json 中

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

    然后在我的路由文件中,我为文档的索引页面设置了一个file_get_contents

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

    而且效果很好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-04
      • 2015-12-31
      • 1970-01-01
      • 2023-04-07
      • 2018-10-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多