/
zroneFrameWork.php
executable file
·59 lines (51 loc) · 1.38 KB
/
zroneFrameWork.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* Created by PhpStorm.
* User: zrone
* Date: 16/1/4
* Time: 05:57
*/
defined( "APP_PATH" ) || define( "APP_PATH", dirname( __FILE__ ) );
zroneFrameWorkAutoLoad();
/**
* 设置自动加载方法
*/
function zroneFrameWorkAutoLoad()
{
spl_autoload_register( 'zroneClassLoader' );
}
/**
* 自动加载
*
* @param $className
*/
function zroneClassLoader( $className )
{
$path = array(
str_replace( "\\", "/", ( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . "Vendor/" ) ),
str_replace( "\\", "/", ( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . "FrameWork/" ) ),
str_replace( "\\", "/", ( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . "Application/" ) )
);
if( isset( $path ) && is_array( $path ) ) {
$Iterator = new ArrayIterator( $path );
$Iterator->rewind();
$pathString = "";
while( $Iterator->valid() ) {
$pathString .= $Iterator->current() . ";";
if( $Iterator->key() == count( $path ) - 1 ) {
$pathString = rtrim( $pathString, ";" );
}
$Iterator->next();
}
set_include_path( $pathString );
spl_autoload_extensions( ".php, .class.php" );
spl_autoload( $className );
} else {
try {
throw new Exception( "<code style='color: red; font-size: 22px; display: block; text-align: center; height: 40px; line-height: 40px;'>I'm sorry, my dear! The FrameWork is Wrong……😫</code>" );
}
catch( Exception $e ) {
echo $e->getMessage();
}
}
}