Google+ Followers

Tuesday, November 8, 2016

Is your Drupal 8 site crashing on PHP 7?

I ran into this problem on a Drupal 8 site running on bleeding edge technology. The site would not come up and it would display an error coming from Symfony "Request.php".
It turns out that PHP 7 has some cool performance features including a feature where PHP will not create the standard global variables (like $_SERVER) if it doesn't see any references to them in the PHP code. The problem was that there were references to the global variables in Symfony, but there were no references within "index.php", so Symfony would crash the drupal site when it tried to access the $_SERVER global variable.
A quick fix was to add this line to index.php: "$server = $_SERVER;" and the site was up and running.