Nurul Alam Anik Nurul Alam Anik - 4 months ago 31
AngularJS Question

Laravel 5.2 view set to public folder

I am trying to make my routes access to public folder as i am trying to use laravel as api and angular as frontend. I have changed the view file from config folder from

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


To

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


in my public folder i have created a views folder and placed a file called test.html
Now

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

return view('test.html');

});


it shows error

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}()


Do you know what i am doing wrong?

Solved it . It was a silly mistake. Turns out I should have stick with php. It does not load html via route.
rename the file from index.html to index.blade.php and it started to work. and change the route return view('test');

Update : Problem fixed.

I was able to create virtual host on my localhost.

Answer

The problem is that U use return view('test.html') on html file! Its wrong, view should be use for php blade templates. Instead return conent of your file (below code I copy-paste from my project FilesController):

use Response;
...

public function downloadFile(Request $request)
{

    ...

    return Response::download(path_to_your_file, download_file_name);

}

and in routes.php file instead of Route::get('/',function(){... put:

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