JoshyPHP I didn't say that max_execution_time should be set arbitrarily high in production. 4lan4raujo said it was a local server and in this case, increasing max_execution_time will help him (and us) diagnose the issue.
It is different when you mention to "help him or us diagnose the issue" but when is not said an inexperience user may leave it that way or make it higher making them think that, that is the way to fix things.
At the end you had the right answer but is still not the solution since its the script that is taking longer than what the parcer is allowing, that is why I said that having a timer to make sure the call to the URL doesn't last longer than it should as some online services may no loner be available, could have a never ending load with out a response and many other issues that are out of the applications control, but it can control the time it should wait before closing the connection .
Also like I said before and what @4lan4raujo just did making this setting larger than what it should be can end up causing more problems than fixing things.
Here I am quoting PHP.NET max_execution_time
This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server. The default setting is 30. When running PHP from the command line the default setting is 0.
30 seconds should be more than enough for very process intensive scripts but making a call to a URL to get a response should not be one of them.
JoshyPHP Not everyone can change their server settings and not everyone has access to the cURL extension. You said that cURL "is always the best at this because you can give it a timer for it to wait". I corrected you on that; HTTP streams have a timeout context option in addition to the default socket timeout. You can read about it in the manual page that I linked.
Yes you did corrected me by pointing out the function on php.net yet is not about you or me being right is about the function in question that is calling a service to minify the JS file but it does not have 2 things that should be important like you just pointed out which could help diagnose the problem.
1. Its not testing if allow_url_fopen is enable to make sure that file_get_contents can get data from a URL
2. there is no time limit set except to rely on the one set by default_sucket_timeout which could be longer than the one set by max_execution_time.
That is why I said always test if one function or library is available if not try the next best thing if available to make sure that the function can be executed, specially when you're relying on an online service. What if the site won't work because the application cannot reach the service or the service is temporary unavailable or no longer available.
At this point the more and more I look at this function I am just hoping that is not something required or that can easily be skip if not available also be set as an option to enable or disable it.
JoshyPHP You say "A good developer should always be aware". That's not the same thing as trying to cater to every badly configured instance of PHP out there. Development cost, maintenance cost and code complexity have to be considered.
That is true, but being aware of such things as a developer is very important in making an application that works well and doesn't require a programmer to identify the problem.
JoshyPHP I'd also like to remind you that there's no indication that this error originates from a lack of support for HTTP streams. As I said earlier, if it was the case the error message would be different. Specifically, it would be something like that:
Yes I understand that and I also said that sometimes a function may end up failing without errors for many different problems and errors will be different and this type of errors may end up not setting a variable and may not even display any errors.
Anyway I do hope people understand whats going on here and to never set max_execution_time to more than 30 seconds unless you're testing or debugging to see which script/function is tying up the server and why, once you're finish debugging make sure to set it back down to its default setting. And NEVER go crazy setting this to more than 60 seconds unless you know what you're doing.