autoload.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Register basic autoloader that uses include path
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. use Magento\Framework\Autoload\AutoloaderRegistry;
  9. use Magento\Framework\Autoload\ClassLoaderWrapper;
  10. /**
  11. * Shortcut constant for the root directory
  12. */
  13. define('BP', dirname(__DIR__));
  14. define('VENDOR_PATH', BP . '/app/etc/vendor_path.php');
  15. if (!file_exists(VENDOR_PATH)) {
  16. throw new \Exception(
  17. 'We can\'t read some files that are required to run the Magento application. '
  18. . 'This usually means file permissions are set incorrectly.'
  19. );
  20. }
  21. $vendorDir = require VENDOR_PATH;
  22. $vendorAutoload = BP . "/{$vendorDir}/autoload.php";
  23. /* 'composer install' validation */
  24. if (file_exists($vendorAutoload)) {
  25. $composerAutoloader = include $vendorAutoload;
  26. } else if (file_exists("{$vendorDir}/autoload.php")) {
  27. $vendorAutoload = "{$vendorDir}/autoload.php";
  28. $composerAutoloader = include $vendorAutoload;
  29. } else {
  30. throw new \Exception(
  31. 'Vendor autoload is not found. Please run \'composer install\' under application root directory.'
  32. );
  33. }
  34. AutoloaderRegistry::registerAutoloader(new ClassLoaderWrapper($composerAutoloader));