Reputation: 681
when we want to return the "welcome" view, is there any different between return View::make("welcome") and return Response::view("welcome")?
if there is different, what is it? when we should use Response::view(), when we should use View::make()?
Upvotes: 2
Views: 1715
Reputation: 4081
I'm not a Laravel programmer, but in most of the frameworks I've used, you usually have two options for views: 1) return the view as a string or 2) output the view directly to the response stream. It sounds to me like View::make()
might be the former and Response::view()
the latter. You can test this by trying to set the value of Response::view()
to a variable, and then see if you can output that variable later in execution. If it does indeed render the response directly to output I believe you will get a "headers already sent" error when you try to output after the Response::view()
call.
Upvotes: 1
Reputation: 643
Each response contains a view. In your example, there is no difference. But using Response::view() you can also set response headers.
Response::view('hello')->header('Content-Type', $type);
View::make is always HTML, Response can be XML, JSON..
Upvotes: 5