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:
<?php
....
....
echo "return response";
exit();
?>
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....
Do you like below Tutorials ?
- PHP Laravel 5.5 - import export data into excel and csv using maatwebsite
- Laravel 7.x and 6.x create custom facade example from scratch
- Node JS - Get Real time online users counter using socket io example
- PHP Laravel 7.x and 6.x - Bootstrap Admin Theme Integration example from scratch
- MySQL Query - How to select records of today to next Sunday ?
- Laravel 7.x and 6.x - username custom validation example
- Laravel 5.5 - Import Extract zip file using chumper/zipper package
- PHP Laravel Set Custom Validation Error Messages Example