Laravel 5 json response from controller exampleBy Hardik Savani | May 11, 2016 | | 5536 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 get size of directory in MB Laravel 5?
- Laravel 5 clear cache from route, view, config and all cache data from application
- Laravel 5 create custom artisan command with example
- Sql function remove numeric characters from column example
- How to resolve - tokenmismatchexception in verifycsrftoken.php Laravel 5 Ajax ?
- How to create Laravel Resource Controller example?
- Laravel 5 amazon s3 file upload tutorial - Part 1
- How to clear log file using command in laravel 5 ?