Why does file_get_contents work with google.com but not with my site?

痞子三分冷 提交于 2019-11-27 15:11:54

For anyone having this problem using PHP Built-in web server (with Laravel in my case), it is caused by your request being blocked by file_get_contents() / curl functions.

Docs of dev server say that

PHP applications will stall if a request is blocked.

Since the PHP built-in server is single threaded, requesting another url on your server will halt first request and it gets timed out.

As a solution, you can use nginx (LEMP stack) or other web servers.

Edit: As of now, I really suggest you to use Homestead as development environment for PHP projects. It saves you lots of work with configuration, creation of virtual hosts and DB configuration for more projects.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!