PHPackages                             yeahphp/classloader - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. yeahphp/classloader

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yeahphp/classloader
===================

php class autoloader

05PHP

Since Sep 30Pushed 7y agoCompare

[ Source](https://github.com/yeahphp/classloader)[ Packagist](https://packagist.org/packages/yeahphp/classloader)[ RSS](/packages/yeahphp-classloader/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

YeahPHP类文件加载器 - ClassLoader
---------------------------

[](#yeahphp类文件加载器---classloader)

> `YeahPHP`类加载器遵守`PSR-4`和`PSR-0`命名空间规范,具体使用请看下面介绍

- 首先加载`ClassLoader`文件

```
require "yourpath/src/yeahphp/Loader/ClassLoader.php";
```

- 创建一个类加载器对象

```
$classLoader = new ClassLoader();
```

- 添加一个PSR-4命名空间规范的前缀

```
$classLoader->addPsr4($prefix, $directory);
```

> 参数解释

参数名称说明$prefix命名空间前缀$directory命名空间前缀对应的路径- 添加一个PSR-0命名空间规范的前缀

```
$classLoader->addPsr0($prefix, $directory);
```

> 参数解释

参数名称说明$prefix命名空间前缀$directory命名空间前缀对应的路径- 添加类的映射

```
$classLoader->addClassMap($class, $file);
```

> 参数解释

参数名称说明$class完整的类名称,包含命名空间$file类文件路径- 通过`classmap`文件批量添加类的映射

```
$classLoader->addClassMapFromFile($file);
```

> 参数解释

参数名称说明$fileclassmap文件路径> `classmap` 文件返回结果为一维数组,格式如下

```
return array(
    "类名称1" => "类文件路径1",
    "类名称2" => "类文件路径2",
    // ...
);
```

- 注册类自动加载器

```
$classLoader->register($throw, $prepend);

```

参数名称说明$throw是否允许抛出异常, 默认为 `true`$prepend是否将加载器添加到队列之首, 默认为`false`- 卸载类自动加载器

```
$classLoader->unregister();

```

> 在项目中,你可以直接加载`autolaod`文件,该文件已经为您初始化了类加载器和一些基础工作

```
require "yourpath/src/yeahphp/Loader/autoload.php";
```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/43714961?v=4)[yeahphp](/maintainers/yeahphp)[@yeahphp](https://github.com/yeahphp)

---

Top Contributors

[![vnaki](https://avatars.githubusercontent.com/u/13231421?v=4)](https://github.com/vnaki "vnaki (1 commits)")[![yeahphp](https://avatars.githubusercontent.com/u/43714961?v=4)](https://github.com/yeahphp "yeahphp (1 commits)")

### Embed Badge

![Health badge](/badges/yeahphp-classloader/health.svg)

```
[![Health](https://phpackages.com/badges/yeahphp-classloader/health.svg)](https://phpackages.com/packages/yeahphp-classloader)
```

###  Alternatives

[ite/form-bundle

Improve Symfony 2 forms by adding new features and integration with popular JavaScript libraries and jQuery plugins.

1420.1k](/packages/ite-form-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
