Change record status: 
Project: 
Introduced in branch: 
8.x
Introduced in version: 
8.0-alpha3
Description: 

The Composer ClassLoader is used to handle any class loading. This allows loading of any Drupal classes or any third-party vendor libraries.

API changes

Autoloading

Composer provides an autoload.php file which registers its class loader and all required namespaces. If you are manually bootstrapping Drupal, ensure this file is included beforehand so that the classes are available:

Drupal 7
<?php
 
require_once 'drupal/core/includes/bootstrap.inc';
?>
Drupal 8
<?php
 
require_once 'drupal/core/vendor/autoload.php';
  require_once
'drupal/core/includes/bootstrap.inc';
?>

Interacting with the Class Loader

In most cases, class namespaces are already registered for you and you should not have to worry about registering the class namespaces yourself. There might be times, however, where you need direct access to the class loader object itself. The class loader instance is available by calling the drupal_classloader() function. By calling this function, you have access to register additional namespaces, interact with its class map, etc. This is a Composer\Autoload\ClassLoader object.

Drupal 7

In Drupal 7, there are a number of contributed modules that allow interacting with a class loader. Some of these include ClassLoader, X Autoload, etc.

Drupal 8
<?php
  $loader
= drupal_classloader();
 
$loader->add('MyNamespace', __DIR__);
?>
Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done