Laravel 5.2视图设置为公用文件夹

时间:2016-07-26 10:19:04

标签: angularjs laravel angular-ui-router single-page-application

我正在尝试让我的路由访问公共文件夹,因为我正在尝试使用laravel作为api和angular作为前端。我已经从

的配置文件夹中更改了视图文件
    'paths' => [
    realpath(base_path('resources/views')),
    ],

    'paths' => [
    realpath(base_path('public/views')),
],

在我的公共文件夹中,我创建了一个views文件夹并放置了一个名为test.html的文件 现在

Route::get('/',function(){

return view('test.html');

});

显示错误

    in FileViewFinder.php line 137
at FileViewFinder->findInPaths('test.html', array('C:\xampp\htdocs\customer_portal\public\views')) in FileViewFinder.php line 79
at FileViewFinder->find('test.html') in Factory.php line 165
at Factory->make('test.html', array(), array()) in helpers.php line 779
at view('test.html') in routes.php line 36
at RouteServiceProvider->{closure}()

你知道我做错了什么吗?

1 个答案:

答案 0 :(得分:0)

问题是你在html文件上使用了返回视图(' test.html')!它错了,视图应该用于php刀片模板。而是返回文件的conent(下面的代码我从我的项目FilesController复制粘贴):

use Response;
...

public function downloadFile(Request $request)
{

    ...

    return Response::download(path_to_your_file, download_file_name);

}

并在routes.php文件而非Route::get('/',function(){...放置:

Route::get('/', 'FilesController@downloadFile');