From e8e0ab3b216872b42a0401732b412aa5ee4b7759 Mon Sep 17 00:00:00 2001
From: Mac_Weber <Mac_Weber@789986.no-reply.drupal.org>
Date: Sat, 28 Jan 2017 00:57:38 -0200
Subject: [PATCH] Issue #2691003 by mpdonadio, Mac_Weber, anoopjohn,
 hussainweb, RobLoach: Catch error(s) from composer install not being run and
 return friendly error

---
 autoload.php | 12 +++++++++++-
 index.php    |  8 ++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/autoload.php b/autoload.php
index 1e5ad34..66430f0 100644
--- a/autoload.php
+++ b/autoload.php
@@ -11,4 +11,14 @@
  * @see core/modules/statistics/statistics.php
  */
 
-return require __DIR__ . '/vendor/autoload.php';
+$autoloader = include __DIR__ . '/vendor/autoload.php';
+
+if (!$autoloader) {
+  header('500 Internal Server Error');
+  print 'Dependencies error! The system cannot access some files at the <code>vendor</code> folder.<br>' . PHP_EOL .
+        'Did you run <code>composer install</code>? You may also need to check the folder permissions, too.<br>' . PHP_EOL .
+        'Refer to the <a href="https://www.drupal.org/documentation/install/download#git">the Drupal installationg guide</a> for instructions on installing with Composer.' . PHP_EOL;
+  exit();
+}
+
+return $autoloader;
diff --git a/index.php b/index.php
index 750dc28..7216bc8 100644
--- a/index.php
+++ b/index.php
@@ -13,6 +13,14 @@
 
 $autoloader = require_once 'autoload.php';
 
+if (!class_exists('\Drupal')) {
+  header('500 Internal Server Error');
+  print 'Dependencies error! The system cannot access some files at the <code>vendor</code> folder.<br>' . PHP_EOL .
+    'Did you run <code>composer install</code>? You may also need to check the folder permissions, too.<br>' . PHP_EOL .
+    'Refer to the <a href="https://www.drupal.org/documentation/install/download#git">the Drupal installationg guide</a> for instructions on installing with Composer.' . PHP_EOL;
+  exit;
+}
+
 $kernel = new DrupalKernel('prod', $autoloader);
 
 $request = Request::createFromGlobals();
-- 
2.8.1

