php - Zend Framework 2.4: Redirect results in blank page on server, works locally
Introduction
- Me and my team are using the Zend Framework 2.4.2 for the first time
- Our goal is to build a simple portal with an authorization module and table- or list-based content
- We've been working on this for a few weeks now and haven't found a solution to our problem yet
Problem
In general, Zend works perfectly on a local machine using XAMPP Apache. However, when deploying it on a remote server, everything works except for redirects. Whenever there is a command like
return $this->redirect()->toRoute('foo');
the browser just shows a blank page (though it redirects perfectly on XAMPP).
System
- We use the Zend Skeleton Application with the Album Modul. We also implemented an authorization module which works very similarly and uses redirects in the same fashion.
- Locally, we use XAMPP Version 1.8.3 and PHP 5.5.15.
- We tested our application on two servers (1&1 and Strato) and different PHP versions (5.3, 5.5, 5.6). All of the configurations result in the same behavior (blank page when redirecting).
What we ruled out
- Case sensitivity and path-related causes can be ruled out. When Zend cannot find a path, it shows an error message.
- Different PHP versions have been tested, so the version is probably not a cause. We cannot say the same about the configuration.
- Access rights on the server can be ruled out as a cause. We tried different configurations here.
We researched a lot on redirects and server configuration, but noone else seems to have this problem. In fact no one ever talks about problems on the server, just general problems with the framework. We are thankful for every thought and idea.
Answer
Solution:
I finally found a solution!
I needed to make a copy of my local php.ini file and paste it in the public/ folder of my Zend application. The server behaves in a way that it loads a standard php.ini if there is none. Now it uses the php.ini with the correct settings. Apparently, there are some few settings necessary for Zend's redirects to work. Naturally, I had to comment out all of the local paths in the copy of the php.ini. Nevertheless, thank you for your input!