The preload script generated by the module doesn't work as it could contain files which are present in modules. These files may, in turn, refer to classes, interfaces, or traits which might not have yet been loaded. Since composer cannot find such classes in modules, we have to explicitly add them to the autoloader similar to this:

/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require_once '/app/web/autoload.php';
$loader->addPsr4('Drupal\field\\', "/app/web/core/modules/field/src/");
$loader->addPsr4('Drupal\views\\', "/app/web/core/modules/views/src/");

Comments

hussainweb created an issue. See original summary.

  • hussainweb committed fa92bca on 1.x
    Issue #3160022: Add PSR-4 autoloading for Drupal modules to preload...
hussainweb’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.