0

Trying to debug a composer error that's happening on my windows machine and not my linux server. Here's the code I'm trying to execute

$url = "https://packages.zendframework.com/packages.json";
var_dump(file_get_contents($url));

When I execute this, I get something like: http://grab.by/pSFI

As you can tell, the weird utf8 character at the beginning should not be there. It does not happen with non-secure protocol (but this url with 301 to secure anyways, so it's not possible to demonstrate).

Any ideas? Is it an openssl dll issue?

sb8244
  • 152
  • 10

2 Answers2

1

This was a windows setup issue that was solved by using xamp instead of wamp. There is a bug in the php build used by my wamp instance that would mess up file_get_contents on ssl destinations. It is working correctly after switching to xamp.

sb8244
  • 152
  • 10
0

These steps would usually do the trick as they are the only reasons I can think of offhand where I've seen that character.

  1. Open your file.
  2. Make sure it has UNIX line endings.
  3. Trim the white space on save.
  4. Make sure there is nothing before the first character. ( Hit backspace for fun before first character, if you don't see anything, in case a control character somehow got copy pasted in that you can't see )
  5. Make sure your server is returning UTF-8 encoded headers

Also, do not develop in different environments... all of them should match. There can be plenty of quirks that are different between different systems. I even had memcache issues on one environment, but not the other, before we got all environments synced. Even worse, you might not see a bug on your dev environment that pops up in production... and then you won't be able to debug it.

Dave Stein
  • 8,653
  • 13
  • 56
  • 104
  • This URL is not in my control and is verified to be working in other environments. The character also changes every execution and is seemingly random – sb8244 Sep 02 '13 at 04:30
  • What do you mean by other environments? Is the sandbox working, but production isn't or visa versa? Did you double check headers? – Dave Stein Sep 02 '13 at 06:39
  • Everything works as it should on my linux VM. I prefer to do dev on my Windows side due to simplicity and partially laziness. I'm almost certain this is a windows php openssl issue but can't find any solutions – sb8244 Sep 02 '13 at 14:03
  • Updated my answer. It might be easier to use Windows, but you won't be able to prove it's a winows issue until you switch over all the way - and then you won't care since it'll be working ;) – Dave Stein Sep 02 '13 at 17:18
  • Sorry that I cannot accept your answer because it didn't address the core issue. There is definitely a bug in the php build I'm using, and switching to xamp fixed that. It is not always feasible to develop in the deployed environment, and not always desired. – sb8244 Sep 05 '13 at 00:05
  • I can understand not accepting my answer, but what reason would you want to develop in a different environment, or be unable to? Granted my dev box isn't load balanced like my pre and production environments, but it uses all the same tech such as PHP versions, centOS, etc – Dave Stein Sep 05 '13 at 00:07
  • Well, I was personally trying to setup this development environment for a number of students who are using Windows machines. Not to say that they don't have access to linux, or that they don't know how to use it, it was just simpler for them to have it setup on Windows where they are familiar to developing. I totally understand and appreciate developing on the same environment, but it's not always practical just due to comfort and setups of machines. – sb8244 Sep 07 '13 at 03:01
  • Ah that makes more sense – Dave Stein Sep 08 '13 at 21:58