Laravel 5 json response from controller exampleBy Hardik Savani | May 11, 2016 | | 10627 Viewer | Category : Laravel
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'];
- How to count number of files in directory PHP?
- PHP Laravel – How to solve “You need to specify a file path to store the seed laravel ” ?
- Laravel 5 - Create modular structure application example using L5Modular package
- Bootstrap notification popup box example using bootstrap-growl JS plugin with demo
- How to solve "Cannot find module 'bplist-parser'" ?
- How to check file is exists or not in PHP?
- Laravel 5 - How to prevent browser back button after user logout?
- How to use collapse example in Bootstrap?