Problem/Motivation
We already inject Composer's autoloader into DrupalKernel
, yet drupal_classloader()
creates its own classloader with a hardcoded reference to Drupal's core/vendor/autolod.php
. Therefore it is not possible to use a different autoloader simply by passing a different one into DrupalKernel
.
Proposed resolution
Always use DrupalKernel
's autoloader. For this purpose a getClassLoader()
method is introduced on DrupalKernelInterface
. This is consumed by drupal_classloader_register()
. Alternatively, drupal_classloader_register()
could be replaced directly by a new method on the kernel or the already existing classloaderAddMultiplePsr4()
. In order to still support ApcClassLoader
for PHP 5.3 a setClassLoader()
method is introduced. This is (optionally) being called from index.php
directly now.
With these changes Drupal can be run with a completely custom classloader (as long as that classloader contains the right classes, obviously).