承接 redcatphp/autoload 相关项目开发

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

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

redcatphp/autoload

最新稳定版本:v2.3.2

Composer 安装命令:

composer require redcatphp/autoload

包简介

Autoload - Simple and Concise PHP Autoloader - PSR-4 convention

README 文档

README

No longer actively maintained. I work now with NodeJS and I recommand you to take a look at di-ninja

Autoload - PHP native dependency manager

Autoload is a simple and concise PHP Autoloader based on universal conventions.
No more need of annoying "require_once" at start of each php file. When needed by php code the class will be dynamicaly loaded and no more load of unused class, increasing performances in same time.
This component is able to autoload all modern PHP frameworks and libraries like Zend, Symfony, PEAR, Aura or many others.

  • PSR-4
  • PSR-0 (retrocompat)
  • classMap API
  • include_path support
  • HHVM hack
  • empty namespace support for root autoload path
  • cache for checked class_exists

Methods usage

simple facade API using global instance

use RedCat\Autoload\Autoload;
/* register "MyNamespace\SubSpace" prefix to "myDirectory/src/myNamespacePath" directory */
Autoload::register('myDirectory/src/myNamespacePath','MyNamespace\SubSpace');

/* register the containing file directory as a root directory for autoload */
Autoload::register(__DIR__);
/* equivalent */
Autoload::register(__DIR__,'');

get global instance

$autoload = Autoload::getInstance();

register and unregister to SPL stack

$autoload->splRegister();
$autoload->splUnregister();

add namespaces

$autoload->addNamespace('Prefix\Of\My\Namespace','target/directory');
$autoload->addNamespace('Prefix\Of\My\Namespace2',[
	'target/directory1',
	'target/directory2',
]);
$autoload->addNamespaces([
	'Prefix\Of\My\Namespace'=>'target/directory/for/my/namespace',
	'Prefix\Of\My\Namespace2'=>[
		'target/directory1',
		'target/directory2',
	]
]);

useIncludePath

$autoload->useIncludePath(true); //default param to true but default property to false

useCache

$autoload->useCache(false); //default param and property to true

addClass and addClassMap

$autoload->addClass('My\Class','path/of/myclass.php');
$autoload->addClassMap([
	'My\Class'=>'path/of/myclass.php',
	'My\Class2'=>'path/of/myclass2.php',
]);

统计信息

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

GitHub 信息

  • Stars: 7
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2015-11-04