定制 loops/autoloader 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

loops/autoloader

最新稳定版本:1.0.3-RC

Composer 安装命令:

composer require loops/autoloader

包简介

Autoloader for package-oriented autoloading with a unique namespace (PSR-4/PSR-0 mixin).

README 文档

README

Autoloader for package-oriented autoloading with a unique namespace (PSR-4/PSR-0 mixin).

Requirements:

  • At least PHP 5.3.

How to use it:

Autoloading

If you do not have composer, call bootstrap:

:::php
  require $path_to_package.'/bootstrap.inc.php';

This library use package-oriented autoloading with a directory for package namespace (PSR-4) and underscore as directory separator for class names (PSR-0).

PSR-4/PSR-0 mixin

Purpose of the PSR-4/PSR-0 mixin autoloading, is to have a package-oriented autoloading with a unique namespace Vendor/Package for the entire package.

In order to keep a usable structure, all classes for this package uses underscores as directory separators.

:::php
  // register PSR-4/PSR-0 mixin autoloading for the package
  \Loops\Autoloader\Psr40::getInstance()->add( 'Vendor\\Package' , $path_to_package_root.'/src' );

  $o = new \Vendor\Package\My_ClassName();
  // look for $path_to_package_root.'/src/My/ClassName.php'

Register a namespace

The \Loops\Autoloader\Psr40 class has been designed has singleton to handle special package-oriented autoloading.

:::php
  // classic implementation for a "bootstrap.inc.php" file that stands on 
  // the package directory
  \Loops\Autoloader\Psr40::getInstance()->add( __NAMESPACE__ , __DIR__.'/src' );

  // add another directory to look for
  \Loops\Autoloader\Psr40::getInstance()->add( __NAMESPACE__ , __DIR__.'/tests' );

  // reset all directories to look for
  \Loops\Autoloader\Psr40::getInstance()->set( __NAMESPACE__ , __DIR__.'/dev' );

This class is loosely based on the \Composer\Autoload\ClassLoader.

Contributors:

Wanna contribute?

There is only one rule to follow: Challenge yourself.

统计信息

  • 总下载量: 30
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-09