read()) { $name = basename($file,'.php'); //不符合命名规则 if(!preg_match('/^[a-z0-9_]+$/i',$name)) continue; //首字母大写的controller为基类控制器,不直接提供响应 if(ord($name{0})>64 and ord($name{0})<91) continue; $path = $d->path.'/'.$file; import_controller($name,$path); } $d->close(); } function import_controller($name, $path) { global $php; require($path); $php->env['controllers'][$name] = array('path'=>$path,'time'=>time()); } /** * 检查是否加载了某个扩展 * @param $ext_name * @return unknown_type */ function require_ext($ext_name) { if(extension_loaded($ext_name)) return true; else return new Error('require php extension '.$ext_name.''); } /** * 导入所有model * @return unknown_type */ function import_all_model() { global $php; $d = dir(Swoole::$app_path.'/models'); while($file=$d->read()) { $name = basename($file,'.model.php'); //不符合命名规则 if(!preg_match('/^[a-z0-9_]+$/i',$name)) continue; //首字母大写的controller为基类控制器,不直接提供响应 if(ord($name{0})>64 and ord($name{0})<91) continue; $path = $d->path.'/'.$file; require($path); $php->env['controllers'][$name] = $path; } $d->close(); } /** * 创建控制器类的文件 * @param $name * @return unknown_type */ function create_controllerclass($name,$hello=false) { $content = ""; $content .= "swoole!';\n"; $content .= " }\n"; } $content .= "}"; file_put_contents(WEBPATH.'/apps/controllers/'.$name.'.php',$content); } /** * 创建模型类的文件 * @param $name * @return unknown_type */ function create_modelclass($name,$table='') { $content = ""; $content .= "