There are two ways to achieve this.
//Utilize Laravel Own Request Class to create a Request either via 'GET' or 'POST' $request = \Request::create("http://www.mylaravelapp.com/api/public-events/nepal", 'GET'); //This will return JsonResponse that contains API response in a data and content protected property $response = \Route::dispatch($request); /** Now you can access the data in following way **/ //METHOD 1 :: Return JSON Response $result = $response->getContent(); //To decode into JSON object json_decode($result); //To decode into JSON array json_decode($result, 1); //METHOD 2 :: To Access JSON Decoded response as an object $response->getData();
file_get_contents
function//Return JSON Response $response = file_get_contents("http://www.mylaravelapp.com/api/public-events/nepal"); //To decode into JSON object $response = json_decode($response); //To decode into JSON Array $response = json_decode($response, true);