概述 快速入门 教程 手册 最佳实践 组件 参考 贡献

发布于 2015-08-27 16:49:54 | 92 次阅读 | 评论: 0 | 来源: 网络整理

The MapClassLoader allows you to autoload files via a static map from classes to files. This is useful if you use third-party libraries which don’t follow the PSR-0 standards and so can’t use the PSR-0 class loader.

The MapClassLoader can be used along with the PSR-0 class loader by configuring and calling the register() method on both.

注解

The default behavior is to append the MapClassLoader on the autoload stack. If you want to use it as the first autoloader, pass true when calling the register() method. Your class loader will then be prepended on the autoload stack.

Usage

Using it is as easy as passing your mapping to its constructor when creating an instance of the MapClassLoader class:

require_once '/path/to/src/Symfony/Component/ClassLoader/MapClassLoader.php';

$mapping = array(
    'Foo' => '/path/to/Foo',
    'Bar' => '/path/to/Bar',
);

$loader = new MapClassLoader($mapping);

$loader->register();
最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务