我们把第三方使用psr规范的类库放在vendor目录下
修改一下autoload函数
12345678910111213141516171819202122 | //psr if (! empty ( $GLOBALS [ '_UCT' ][ 'autoload_psr' ])) { //namespace if (false !== strpos ( $class_name , '\\' )) { $dir = str_replace ( '\\' , DS, ltrim( $class_name , '\\' )). '.php' ; } else { $dir = str_replace ( '_' , DS, $class_name ). '.php' ; } foreach ( $GLOBALS [ '_UCT' ][ 'autoload_psr' ] as $vendor ) { if (! strncmp ( $vendor .DS, $dir , strlen ( $vendor ) + 1)) { $f = UCT_PATH . 'vendor' . DS . $dir ; } else { $f = UCT_PATH . 'vendor' . DS . $vendor . DS . $dir ; } if ( file_exists ( $f )) { return include $f ; } } } |
引用第三方类库
123456789101112131415 | function uct_use_vendor( $vendor ) { if ( empty ( $GLOBALS [ '_UCT' ][ 'autoload_psr' ])) { $GLOBALS [ '_UCT' ][ 'autoload_psr' ] = array ( $vendor ); return true; } if (!in_array( $vendor , $GLOBALS [ '_UCT' ][ 'autoload_psr' ])) { //$GLOBALS['_UCT']['autoload_psr'][] = $app; array_unshift ( $GLOBALS [ '_UCT' ][ 'autoload_psr' ], $vendor ); return true; } return false; } |