Laravel 5 json response from controller exampleBy Hardik Savani | May 11, 2016 | | 3002 Viewer | Category : Laravel
Share this post:
If you are working with REST API then you always need to return json data response that way front-end developer can handle it easily. i created bellow controller method in this method i return json array response, that way you can understand very well. laravel 5 provide response() helper and it will help to response of json object. But if you are working on Core PHP then you have to do json_encode before send output. In laravel you can do it easily like this way:
public function getJsonData()
$myArray = ['id'=>1, 'name'=>'HD'];
- Laravel tokenmismatchexception in verifycsrftoken.php - Solved
- How to hide div after some time using AngularJS?
- How to remove empty values from array in PHP?
- Laravel 5 - Custom Helper Facade Class Example from scratch
- How to import CSV file using mysql
- How to connect mysql database in node js with example?
- Laravel 5 - generate PDF from html view file and download using dompdf