How to return response text/html from controller in laravel 5?

Few days ago, i was working on my new project and project was migrate project php into laravel. I need to migrate apis, So in old php application it returns response as text and i have to keep same response in laravel 5.4 application. So i thought how we can do it, finally i got it, we can do it using response().

response() helper will help to return simple text. So in my php it was like as bellow:

PHP response:




echo "return response";



Now i am going to give example of return response as text/html not json. In this example i am going to use response() for return simple text.

Laravel response in controller method:


* Show the application dashboard.


* @return \Illuminate\Http\Response


public function logActivity(Request $request)


$input = $request->all();

return response('return response');


I hope you found, your solution from here....

July 4, 2017 | Category : PHPLaravel
Related Posts

Blog Search