Anfora 自动装载类
1、目录结构
+ Anfora
| + Autoload
| - ClassLoader.php
| - Autoload.php
- autoload.php
2、注册类加载器
src/Anfora/Autoload.php
class Anfora_Autoload
{
private static $loader; public static function loadClassLoader($class)
{
$class_name = trim($class, '\\');
if ('Anfora\Autoload\ClassLoader' === $class_name) {
require_once __DIR__ . '/Autoload/ClassLoader.php';
}
} public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
} $autoload_function = array('Anfora_Autoload', 'loadClassLoader');
spl_autoload_register($autoload_function, true, true);
self::$loader = $loader = new \Anfora\Autoload\ClassLoader();
spl_autoload_unregister($autoload_function);
$loader->register(true);
return $loader;
}
}
getLoader()
注册类加载器函数并注销
注册全局类加载
loadClassLoader()
引入全局类加载
3、全局类装载
src/Anfora/Autoload/ClassLoader.php
class ClassLoader
{
/* 注册与注销 */ public function loadClass($class)
{
/* 获取文件路径、包含文件,调试信息 */
} public function findFile($class)
{
/* 匹配命名空间规则,返回文件路径 */
}
} function includeFile($file) {
return $include = @include_once $file;
}
Anfora 自动装载类的更多相关文章
- php类自动装载、链式操作、魔术方法
1.自动装载实例 目录下有3个文件:index.php load.php tests文件夹 tests文件夹里有 test1.php <?php namespace Tests; class T ...
- spring Bean类自动装载实现
先贴spring的开发文档,有助于大家学习http://shouce.jb51.net/spring/beans.html#beans-factory-class 一直想研究一下spring bean ...
- Archlinux 的U盘自动装载(一)udisks
为什么要用 udisks + udevil 方式自动装载 U 盘? Gnome 和 KDE 下的很多文件管理器都有自己的U盘装载方案.但我的应用环境为: Archlinux,xorg,Openbox, ...
- spring 组件自动装载示例(@ComponentScan,@Component,@Scope)
今天学习spring的bean组件装载功能,个人不太喜欢xml文件一个个配置bean的方式,所以主要学习测试注解式的自动装载方式.下面将简单说明下@Component的用法,简单入门示例献给大家. ...
- Spring-Boot自动装载servlet
Spring-Boot自动装载servlet 本人spring-boot相关博客均自己手动编写,但技术均从简书 恒宇少年 处学习,该大佬一直是我的偶像,鉴于能充分理解,所以已做笔记的方式留下这些文档, ...
- Spring核心技术(八)——Spring自动装载的注解
本文针对自动装载的一些注解进行描述. 基于注解的容器配置 @Required注解 @Required注解需要应用到Bean的属性的setter方法上面,如下面的例子: public class Sim ...
- Spring深入浅出(二)IOC的单例 ,继承,依赖,JDBC,工厂模式以及自动装载
IOC的单例模式--Bean Spring中的bean是根据scope来决定的. scope有4种类型: 1.singleton:单例模型,表示通过Spring容器获取的该对象是唯一的.常用并且默认. ...
- springboot(二)配置SpringBoot支持自动装载Servlet
Servlet详解:https://blog.csdn.net/yanmiao0715/article/details/79949911 Web 技术成为当今主流的互联网 Web 应用技术之一,而 S ...
- js点击左右滚动+默认自动滚动类
js点击左右滚动+默认自动滚动类 点击下载
随机推荐
- springBoot 全局异常方式处理自定义异常 @RestControllerAdvice + @ExceptionHandler
前言 本文讲解使用 @ControllerAdvice + @ExceptionHandler 进行全局的 Controller 层异常处理,可以处理大部分开发中用到的自自定义业务异常处理了,再也不用 ...
- API权限设计总结
最近在做API的权限设计这一块,做一次权限设计的总结. 1. 假设我们需要访问的API接口是这样的:http://xxxx.com/openapi/v1/get/user/?key=xxxxx& ...
- Selenium Grid和IE /Firefox各种填坑
使用selenium grid的步骤 1.确保hub和node都安装并且配置好了java jdk. 2.在hub上运行以下命令. java -jar C:\Software\selenium\sele ...
- npm 命令
npm instal moduleName [-g] :安装模块,有 -g 或 --global 是全局安装 npm install -g cnpm --registry=https://regis ...
- 【c # 数据库】存储过程
可理解存储过程是方法,快速调用,方便使用. 数据库建立新的存储过程: CREATE PROCEDURE myProc -- Add the parameters for the stored proc ...
- java数据结构分析
java数据结构分析 此文章内容参考于:http://www.cnblogs.com/ysocean/ 一.数据结构总览图 1.数组 2.链表 3.栈 4.队列 5.二叉树 6.堆 7.散列 8.红黑 ...
- nltk分词
1.安装nltk 2.运行如下 >>>import nltk>>> nltk.download('punkt') 3.代码: import nltk sentenc ...
- django filter or 多条件查询
功能:django中实现多条件查询 或关系: from django.db.models import Q return qs.filter(Q(notice_to_group__contains=' ...
- HashMap、Hashtable、ConcurrentHashMap的原理与区别(简述)
HashTable 底层数组+链表实现,无论key还是value都不能为null,线程安全,实现线程安全的方式是在修改数据时锁住整个HashTable,效率低,ConcurrentHashMap做了相 ...
- MySQL索引原理以及查询优化
转载自:https://www.cnblogs.com/bypp/p/7755307.html MySQL索引原理以及查询优化 一.介绍 1.什么是索引? 一般的应用系统,读写比例在10:1左右,而且 ...