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?
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.
These steps would usually do the trick as they are the only reasons I can think of offhand where I've seen that character.
Open your file.
Make sure it has UNIX line endings.
Trim the white space on save.
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 )
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.
Related
I believe I've browsed a ton of different sites, blogs, and whatnots.
My PHP Website works great on my MAMP Stack in my computer (Working on a MAC, please don't judge).
The thing is, whenever I roll my website to my Production Server, running Ubuntu 18.04 (Regular LAMP Stack) I keep getting errors 404 when trying to use the site.
I've analyzed the paths, and the files do exist, however, in my code it's being required as
/Tools/Php/initialScript.php
and the actual path looks like
```/Tools/PHP/initialScript.php````
I've already enabled mod_speling in my server, and restarted the whole thing a few times (more than I care to admit).
Does mod_speling even work for PHP require function?
Any guidance at this point would be appreciated.
Interesting that you mention it works on Mac. Mac paths as far as I know are case-insensitive. Case in point, do cd /to/SoMe/pAth and it will work just fine. On the other hand, Linux is case sensitive.
I would personally just not play loose with case and treat things as though they were case sensitive. Is there something keeping that from being possible?
I have been asked to move a PHP application to another environment. I set up PHP installation, and moved 2 PHP applications and. got that working.
But one application I moved is not working... it just renders a blank screen.
When I say Localhost/ApplicationName, it lists the application folders and PHP files in it. When I click on it, the browser goes blank.
Can somebody point out a step-by step trouble shooting ways to test this?
there are a lot of ways a php file can return a blank page
first make sure the file did work on the previous environment, if it didn't then it's a different issue entirely
do the following in order of what you suspect to be most probable:
you can go into the php.ini file, and set the error variables to the development defaults, then check if it returns any usable errors
^this is what I use all the time for fatal issues, always set it back to it's original afterwards though
or check the errorlogs, as JimL suggested
if it worked on the previous env then you need to find out what the differences are between both environments.
things like, php.ini setting, IIS vs apache or whatever http server, linux vs windows
check if any of the php pages return anything at all (for example, in firefox, rightclick+inspect element, then use the network tab)
if it's a 500 error, the file probably has an error (and the server is configured to return 500 on an error)
if the file isn't too large, you can go through the file and use common programming sense to see if you can easily spot the error (stuff like links to nonexisting files, etc, shouldn't be too hard even without php experience)
when it links to files, also check if the notation is correct for the windows IIS
feel free to give more information in your OP, or in a comment, if you find out any information, and I'll do my best to help
disclaimer, I have no specific IIS knowledge, I work with apache (both windows and linux)
I've gone through nearly every solution I could find in regards to how to treat the newline issues associated with moving from Windows to Linux with a variety of programs yet I still receive server errors.
How I work now is that I have a guest machine in Virtualbox running CentOS. I avoided compatibility issues for a long time by simply running NetBeans in the guest; however, I run this on a laptop with limited memory and while CentOS runs fine for my purposes NetBeans slows to a crawl - I can only disable so many features before its stops being and IDE and becomes a glorified text-only editor. This prompted me to try to find a solution for the compatibility again.
I've tried dos2unix on CentOS with no avail. I've tried programs that can save in the appropriate format (NotePad++ for example) with no luck. I've tried NetBeans loading an existing file, reading that it will respect the existing newline. I've also tried the NetBeans plugin 'Show and Change Line Endings' - a very popular solution - and it still doesn't work (both loading & creating new files.) I uninstalled & reinstalled NetBeans and while PHP files will throw an error, a new HTML file will give me a "Forbidden" page and existing files will throw an error.
I'm pretty much at my wits end given that I cannot find any other compatibility issue aside from the newline, and any amount of searching produces only results regarding newline. I feel like I am missing something here, but even if I take an existing working file and just save it under Window's with the supposed solutions the file breaks.
I think I understand as much as you are having line ending issues causing errors.
In Coda2 (http://www.panic.com) for OS X, it will highlight different new line endings and correct them.
I believe Sublime (http://www.sublimetext.com/2), available for Windows and Linux, will do the same.
Discovered that files moved from Windows to CentOS inherited only permissions for root; using 'chmod' to change permissions to allow all users to read the file allowed the content to be used.
For example: sudo chmod 754 mypage.html
I've recently switched my web server to Centos 6.3, with apache 2.2.15, PHP 5.4.11 and APC 3.1.14.
I started receiving complaints from customers from time to time, that a page is not working, or strange errors appear. I saw that the affected pages have question marks and other strange symbols in random places in the output, even though the sources are OK. When I change a single letter in the source file, the page starts working fine.
I suspect APC, but I cannot find any clue when and why this happens.
I use mercurial to push changes to production, but I've used this approach for years with no problem. Maybe something in the configuration is new now, but sadly I don't keep my old configuration.
Below is a screenshot from the last corruption.
Edit: Here's the response after I've changed a single character in the source, saved it, and then undo the files (same is if I just restart the web server or clear APC opcode cache):
Notice the line numbers didn't match, but it's 100% the same request, so the response should be the same also. The line 111 from the first screenshot should not be there at all. It seems that it's from another source file...
I've changed apc.stat_ctime to 1
Verification with ctime will avoid problems caused by programs such as svn or rsync by making sure inodes haven't changed since the last stat. APC will normally only check mtime.
I'll be watching closely on the problem, because it's occurring once or twice a week and post here if this fixed it.
I am currently developing a web application with Symfony that's supposed to connect to a remote Web-Service. Then synchronise database from the client to the server and vice-versa and some other crap.
The Web-service server is on an IIS in the LAN.
Symfony2 is running with Wamp on my machine.
So, the connexion and request code to the web-service in a simple php script is perfectly functional. Or at least, it does what I want it to do.
And any connexion to the IIS server is perfectly fine.
A bit slow though, but the machine is quite a mess.
Now I put that same code into a Symfony2 class, and here comes the hell.
When I try to load that page, I get a
101 error (ERR_CONNECTION_RESET)
Web-service server's log indicates me that the login, request and response were sent.
So my guess is the problem is comin' from my machine, but not quite sure about it.
The really funny thing : I somehow managed to make it work for about 10 times.
Then 101 again...
I disabled the Windows 7 LAN firewall both side, same result.
Any clue is very welcome.
Thanks.
I spent hours debugging this with a colleague. He was getting the same error but it was working properly on my machine (we're using Windows 7, 64bit, WAMPServer 2.2d, 32bit).
Here is what the culprit was:
- the file TwigEngine.php had Unix-style line endings (LF) on my machine but on his machine it had Windows-style line endings (CR+LF)
- after changing the line endings to LF only, it works fine on his machine too
That would possibly explain the other answer above "all I needed to do is just resave
TwigBundle/TwigEngine.php" if the editor changed the format of the line endings.
The underlying cause was the installation of git, he had picked the default ("Windows-style check-outs") and I had selected "as-is").
After some more research. here is an explanation of the cause for this: https://github.com/symfony/symfony/issues/3216
Hopefully this helps someone else save some time.
I solve the problem...
I set the second parameter of AppKernel in app_dev.php to FALSE and now works fine
$kernel = new AppKernel('dev', FALSE);
I will continue investigating...
I had same problem after 4 hours of "debuging" i found that all I needed to do is just resave
TwigBundle/TwigEngine.php
I have no clue why
In fact, I think (in my case at least) those errors are twig related.
Sometimes, when there's a critical error related to twig logged in app/logs/dev.log, I got that 101.
Those critical errors are often syntaxic, so no real deal here.
And once they are dealt with, no problem anymore.
The strange thing is that sometimes, clearing the cache allows me to load the page 3 or 4 times.
Mike WP made it. TwigEngine need LF line endings to work properly. You can use this console command then you'll have to update/reinstall vendors.
git config --global core.autocrlf input
I had the same issue on Windows using XAMPP, and solved by:
composer require "twig/twig:^2.0"