dongpo2340 2016-12-09 06:06
浏览 43
已采纳

没有前端的Laravel项目

currently I have a standard Laravel 5 proyect, eg:

 Laravel Directory
     app Directory
     bootstrap Directory
     config Directory
     database Directory
     public Directory
     resources Directory
     routes Directory
     storage Directory
     tests Directory
     vendor Directory

what I'm trying to do is to take the public and resources folder out from the application and put it them on a different project, and in that way I'll use the laravel part only for backend purposes and the frontend parte I'll manage it on an outside project. e.g.:

 Laravel Directory
     app Directory
     bootstrap Directory
     config Directory
     database Directory
     routes Directory
     storage Directory
     tests Directory
     vendor Directory

Frontend project
     index.html
     app folder
     css folder
     assets

Any recomendation or ideas to do it ?

  • 写回答

1条回答 默认 最新

  • duan02143 2016-12-09 08:05
    关注

    Removing (or moving) the Public folder is not a good idea, especially due to the fact that the public/index.php file is the entrypoint for the application.
    I personally use both laravel and lumen for a bunch of my REST-API's and it works great, so that thought is not at all wrong.
    Just ignore the views, don't use them and don't expose them from any controller action, but rather return all data from the controllers as JSON instead.

    This is easily done from the controller actions like:

    public function getSomethingAction() {
        return response()->json([
            "some" => "property"
        ]);
    }
    // Which will produce the following json (including headers and all):
    {
        "some": "property"
    }
    

    I would also recommend that you group your routes under a API namespace of some sort:

    Route::group(["prefix" => "api/v1"], function() {
        Route::get('something'...
    });
    

    So now when you call domain.tdl/api/v1/something you will get a neat json response!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog