Download the PHP package helhum/class-alias-loader without Composer

On this page you can find all versions of the php package helhum/class-alias-loader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package class-alias-loader

Class Alias Loader Build Status

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?

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?

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

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

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:

The '::class' constant is not available before PHP 5.5. Under a PHP before 5.5 the mapping file can look like this:

In your root composer.json file, you can decide whether to allow classes to be found that are requested with wrong casing. Since PHP is case insensitive for class names, but PSR class loading standards bound file names to class names, class names de facto become case sensitive. For legacy packages it may be useful however to allow class names to be loaded even if wrong casing is provided. For this to work properly, you need to use the composer optimize class loading information feature.

You can activate this feature like this:

The default value of this option is true.

If no alias mapping is found and case sensitivity is set to true then by default this package does nothing. It means no additional class loading information is dumped and the vendor/autoload.php is not changed. This enables library vendors to deliver compatibility packages which provide such aliases for backwards compatibility, but keep the library clean (and faster) for new users.

In case you want your application to add alias maps during runtime, it may be useful however if the alias loader is always initialized. Therefore it is possible to set the following option in your root composer.json:

Using the API

The public API is pretty simple and consists of only one class with only three static methods, TYPO3\ClassAliasLoader\ClassAliasMap::getClassNameForAlias being the most important one. You can use this class method if you have places in your application that deals with class names in strings and want to provide backwards compatibility there. The API returns the original (new) class name if there is one, or the class name given if no alias is found.

The remaining methods, deal with adding alias maps during runtime, which generally is not recommended to do.

Feedback appreciated

I'm happy for feedback, be it feature requests or bug reports.

Contribute

If you feel like contributing, please do a regular pull request. The package is pretty small. The only thing to respect is to follow PSR-2 coding standard and to add some tests for functionality you add or change.


All versions of class-alias-loader with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.7
composer-plugin-api Version ^1.0 || ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package helhum/class-alias-loader contains the following files

Loading the files please wait ....