Support the ongoing development of Laravel.io →
posted 10 years ago
Requests

I need to make GET/POST requests to php API in subfolder (public/forum/api.php), e.g. not url from routes table.

file_get_contents() doesn't work on localhost for some reason on dev server (port 8000).

// this keeps loading without result

$response = file_get_contents('http://localhost:8000/forum/api.php');

// these works fine

$response = file_get_contents('http://localhost'); // apache index without port

$response = file_get_contents('http://google.com'); // remote call

Navigating in borwser to http://localhost:8000/forum/api.php works fine.

Same results for curl calls.. Any ideas why requests from php to port 8000 freeze? Is there any other way?

Thanks

Last updated 3 years ago.
0

Maybe it has something to do with the fact that localhost:8000 is served by the php built in server ?

Last updated 3 years ago.
0

Most probably, but I can't find a way around it.

Last updated 3 years ago.
0

Ok, I solved it. I wrote about it here http://stackoverflow.com/a/25651196/916682

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

matohavo matohavo Joined 19 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.