1

Recently, I updated from 8.1.8 to 8.1.10 (via composer update). In my local environment (running scotchbox, PHP 5.6.14), it runs fine. When deployed to the staging server (running CentOS 6.7, PHP 5.5.17), the site returns a 500 and writes the following to error_log:

PHP Fatal error: Class 'Drupal\Core\Site\Settings' not found in /home/[site]/public_html/drupal/core/lib/Drupal/Core/DrupalKernel.php on line 964

I copied basically everything except the /sites/ directory, so I don't think I'm missing anything.

I tried restarting httpd to no avail.

It seems like a problem with the autoloader and possibly due to the PHP version mismatch. There are many layers between autoload.php and the DrupalKernel.php bootstrap process. I'm at a loss as to what's going on here. Any help would be appreciated.

  • Have you tried to restart apache? – timodwhit Sep 29 '16 at 0:15
  • I did, question updated to include that info--thanks. – pjbeardsley Sep 29 '16 at 14:48
  • @pjbeardsley I have same issue and updated my php version 5.5 to 5.6 and it works. As 5.6 considered last stable release of PHP. I hope it works – Mudassar Ali Oct 5 '16 at 14:18
  • Did your composer update updated any vendors ? – pbonnefoi Oct 6 '16 at 7:56
  • try composer install . – Shreya Shetty Oct 10 '16 at 6:53
1
+50

It sounds like the changes that composer made to your local environment weren't carried over. Without knowing any of the details of what might be different, you'll have to do some introspection. You can test the autoloader in both your dev/staging environment to tease out what's occurring differently in each environment.

There a few things you can do to test the autoloader:

  • Within index.php you can use the statement var_dump($autoloader) to dump the autoloader; it should have a classMap property which should have a keyed array that maps classes to PHP files. It should include a value for Drupal\Core\Site\Settings.
  • Within vendor/composer/autoload_real.php is the logic that registers the autoloader and includes other autoload_*.php used to build the autoloader object. You can various var_dump() statements to follow the path of execution to make sure the autoloader is being built correctly.
  • Within vendor/composer/ClassLoader.php you use the var_dump($class) statement in the ClassLoader::loadClass($class) method to have PHP spit out classes as the autoloader is including them.
1

I solved a similar problem changing file permissions. Try changing group ownership of files to "www-data" recursively both in vendor and web folder.

chown -R $USER:www-data vendor web

CentOS server should use "apache" instead of "www-data"

chown -R $USER:apache vendor web

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.