PHPackages                             helhum/class-alias-loader - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. helhum/class-alias-loader

Abandoned → [typo3/class-alias-loader](/?search=typo3%2Fclass-alias-loader)Composer-plugin

helhum/class-alias-loader
=========================

Amends the composer class loader to support class aliases to provide backwards compatibility for packages

v1.1.2(6y ago)0261.5kMITPHP &gt;=5.3.7

Since Oct 6Pushed 3y agoCompare

[ Source](https://github.com/helhum/class-alias-loader)[ Packagist](https://packagist.org/packages/helhum/class-alias-loader)[ Docs](http://github.com/TYPO3/class-alias-loader)[ RSS](/packages/helhum-class-alias-loader/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (7)Used By (0)

Class Alias Loader [![Build Status](https://camo.githubusercontent.com/c90a18753adb3467636b76a80bcfb2070cd0f48e46973c44d3b78f371e8fbf95/68747470733a2f2f7472617669732d63692e6f72672f5459504f332f636c6173732d616c6961732d6c6f616465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/TYPO3/class-alias-loader)
==========================================================================================================================================================================================================================================================================================================================

[](#class-alias-loader-)

Introduction
------------

[](#introduction)

The idea behind this composer package is, to provide backwards compatibility for libraries that want to rename classes but still want to stay compatible for a certain amount of time with consumer packages of these libraries.

What it does?
-------------

[](#what-it-does)

It provides an additional class loader which amends the composer class loader by rewriting the `vendor/autoload.php`file when composer dumps the autoload information. This is only done if any of the packages that are installed by composer provide a class alias map file, which is configured in the respective `composer.json`.

How does it work?
-----------------

[](#how-does-it-work)

If a package provides a mapping file which holds the mapping from old to new class name, the class loader registers itself and transparently calls `class_alias()` for classes with an alias. If an old class name is requested, the original class is loaded and the alias is established, so that third party packages can use old class names transparently.

Configuration in composer.json
------------------------------

[](#configuration-in-composerjson)

You can define multiple class alias map files in the extra section of the `composer.json` like this:

```
    "extra": {
        "typo3/class-alias-loader": {
            "class-alias-maps": [
                "Migrations/Code/ClassAliasMap.php"
            ]
        }
    },

```

Currently these files must be PHP files which return an associative array, where the keys are the old class names and the values the new class names. Such a mapping file can look like this:

```
