I am learning in Laravel and I got a strange error with Laravel 5.4 and XAMPP 5.6.23. Let say I have a Laravel app with APIController and UserController. In APIController.index() function:
public function index()
{
$users = User::all();
return response()->json($users);
}
In UserController.index() function:
public function index()
{
$url = route("api.index");
$content = @file_get_contents($url);
dd($content);
}
Note route("api.index") return "http://localhost:8000/api", and is mapping to the APIController.index() function. In php.ini I have "allow_url_fopen" = On. The problem is file_get_contents() always exceed maximum time. When I replace $url = "https://jsonplaceholder.typicode.com/comments", however, it works. I dont know what's wrong cuz Laravel doesnt show me any error rather than Maximum time exceeded. Any one can help? Thank you!
via Chu Văn Hợp