I have Drupal 8 website created with composer. I put all files to my remote server in the sitename/www/ but my page won't load. I receive such an error:

Fatal error: Class 'Drupal\Core\DrupalKernel' not found in /home/bx273629/drupal8.com.ua/www/index.php on line 16

I think it is because I created that website with the Composer. Does any body know how to deploy correctly such a websites?

Website perfectly works locally!

I have such an error:

'Fatal error: require(): Failed opening required '/home/bx273629/drupal8.com.ua/www/../vendor/autoload.php' (include_path='.:/usr/local/pear/php56') in /home/bx273629/drupal8.com.ua/www/autoload.php on line 17'

And on the line 17 of these file I have such a string:

return require DIR . '/../vendor/autoload.php';

It is from the outer folder which was installed with composer.

  • Have you tried to run: composer update?
    – kenorb
    Aug 21 '17 at 8:38
  • For what? Where?
    – rick1
    Aug 21 '17 at 9:01
  • Composer is not for deploying a site, but for copying all the dependencies. In the sites where I don't have access to a remote shell, I just copy with FTP the files on the remote server, after I copied all the dependencies with Composer, in local.
    – apaderno
    Aug 21 '17 at 9:08
  • It sounds like you aren't copying all the files.
    – apaderno
    Aug 21 '17 at 9:10
  • I use filezilla to replace all content of web folder to my remote server
    – rick1
    Aug 21 '17 at 9:36

I had faced this problem a while ago. After lot of research, I found that running composer install from the site root resolves any problem.

  • This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
    – mradcliffe
    Aug 22 '17 at 21:38
  • I had faced this problem a while ago, after lots of research, I found the step I mentioned clear the problem. Hence I thought of sharing it. I did not have any questions or asked any questions in my response! @mradcliffe, I am not sure why this does not qualify as an answer. can you please explain?
    – Sensimple
    Aug 23 '17 at 7:32
  • When answering a question, avoid starting with try with, or users will think you are trying to get feedback from the OP, as if you weren't sure about that working, and you needed a feedback from the user who asked the question to give a better answer.
    – apaderno
    Sep 11 '17 at 20:37

You need to copy your vendor/ folder (generated by composer update on your local) into /home/bx273629/drupal8.com.ua/ dir (one level above www/), then index.php and rest files into /home/bx273629/drupal8.com.ua/www/ as normally vendor/ folder should be copied one level above of Drupal root (so it's not accessible from the outside), so the file www/../vendor/autoload.php will exists (same localization as on local).

If you cannot copy to the folder above your docroot (www/) due to access restriction, modify your autoload.php to point to the current folder, e.g.

return require __DIR__ . '/vendor/autoload.php';

and copy the vendor/ along with your Drupal files.

  • I did this but now has an error Fatal error: Class 'Drupal\Core\DrupalKernel' not found in /home/bx273629/drupal8.com.ua/www/index.php on line 16 in that line I have follwoing code $kernel = new DrupalKernel('prod', $autoloader);
    – rick1
    Aug 21 '17 at 12:40
  • @rick1 Have you run composer update command in you Drupal root directory on your local to download dependencies?
    – kenorb
    Aug 21 '17 at 15:53
  • yes but it won't work. I mean I have the same error
    – rick1
    Aug 21 '17 at 18:08
  • @rick1 Do you still have error about opening www/../vendor/autoload.php? are you sure the file exists there?
    – kenorb
    Aug 21 '17 at 20:41

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.