承接 horde/autoloader 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

horde/autoloader

Composer 安装命令:

composer require horde/autoloader

包简介

Autoloader library

README 文档

README

PSR-0 and PSR-4 compliant autoloader for PHP 8.0+

Why Horde Autoloader?

Horde Autoloader predates PSR-0 and is mostly maintained for legacy and educational purposes. Horde itself primarily uses composer autoloader as does everybody else. Remaining calls into Horde Autoloader from the Horde Framework are going to be removed step by step.

If you need a config-is-code, self-contained, PSR-0 capable autoloader and composer autoloader is not an option, give it a try. Your reasons are yours.

Features

  • PSR-4 Support - Autoloading with namespaces
  • PSR-0 Support - PEAR-style autoloading without namespaces, underscores as subdir separators.
  • Classpath Mappers - Application, Prefix, PrefixString patterns
  • PHP 8.0+ - Full type safety and modern features
  • LIFO Ordering - Last-added mapper searched first
  • Callback Support - Execute code after class loads
  • No Dependencies - Self-contained library

Quick Start

Modern (PSR-4 with PSR-0 support)

// Autoloader bootstraps itself - require files explicitly
require_once __DIR__ . '/vendor/horde/autoloader/src/Autoloader.php';
require_once __DIR__ . '/vendor/horde/autoloader/src/ClassPathMapper/Psr4.php';

use Horde\Autoloader\Autoloader;
use Horde\Autoloader\ClassPathMapper\Psr4;

$autoloader = new Autoloader();
$psr4 = new Psr4(enablePsr0Fallback: false);
$psr4->addNamespace('Acme\Log', __DIR__ . '/vendor/acme/log/src');
$autoloader->addClassPathMapper($psr4);
$autoloader->registerAutoloader();

Legacy (PSR-0 based PSR-0)

// Autoloader bootstraps itself - require files explicitly
require_once __DIR__ . '/vendor/horde/autoloader/lib/Horde/Autoloader.php';

$autoloader = new Horde_Autoloader();
$autoloader->addClassPathMapper(
    new Horde_Autoloader_ClassPathMapper_Default(__DIR__ . '/lib')
);
$autoloader->registerAutoloader();

Installation

composer require horde/autoloader

Documentation

Requirements

  • PHP 8.0 or higher

Key Differences: PSR-0 vs PSR-4

Feature PSR-0 PSR-4
Underscores Converted to / Preserved as-is
Namespace mapping Simple path Prefix → base directory
Top-level classes Allowed Rejected (requires namespace)
Multiple base dirs No Yes

PSR-0 Example

// Class: Vendor_Package_Class_Name
// Maps to: vendor/Vendor/Package/Class/Name.php

PSR-4 Example

// Prefix: Vendor\Package → /vendor/package/src
// Class: \Vendor\Package\Class_Name
// Maps to: /vendor/package/src/Class_Name.php (underscore preserved!)

Available Mappers

Modern (src/)

  • Psr4 - PSR-4 compliant autoloader with namespace prefix mapping
  • DefaultMapper - PSR-0 compliant mapper (underscores → directories)
  • Application - Application-specific MVC pattern mapper
  • Prefix - Regex-based prefix matching
  • PrefixString - Fast case-insensitive string prefix matching

Legacy (lib/)

  • Horde_Autoloader_ClassPathMapper_Default - PSR-0 mapper
  • Horde_Autoloader_ClassPathMapper_Application - Application mapper
  • Horde_Autoloader_ClassPathMapper_Prefix - Regex prefix
  • Horde_Autoloader_ClassPathMapper_PrefixString - String prefix

Testing

# Run all tests
phpunit

# Run specific test suites
phpunit --testsuite unit        # Legacy PSR-0 tests
phpunit --testsuite modern      # Modern PSR-4 tests
phpunit --testsuite integration # Real file loading tests

License

LGPL-2.1-only

Links

Credits

  • Authors: Bob Mckee, Chuck Hagenbuch
  • Maintainers: Jan Schneider, Ralf Lang

horde/autoloader 适用场景与选型建议

horde/autoloader 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.62k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 11 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 horde/autoloader 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 horde/autoloader 我们能提供哪些服务?
定制开发 / 二次开发

基于 horde/autoloader 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.62k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 7
  • 依赖项目数: 19
  • 推荐数: 2

GitHub 信息

  • Stars: 1
  • Watchers: 6
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-2.1-only
  • 更新时间: 2022-11-10