此代码是把大商创的2.7.3版本admin里面的php换成laravel的routes
public function saveRoute(){$dir = 'D:/WWW/dsc2.7.3/admin/';$handler = opendir('D:/WWW/dsc2.7.3/admin/');$arr = [];while( ($filename = readdir($handler)) !== false ){//略过linux目录的名字为'.'和‘..'的文件if($filename != "." && $filename != ".."){$arr[] = $filename;//输出文件名
// echo $filename.'<br>';}}closedir($handler);$newDir = 'D:/WWW/new/route.php';$myfile = fopen($newDir, "w+");fwrite($myfile, "<?phpr");foreach ($arr as $key =>$value){if(!str_is('*.php',$value)){continue;}$name = $this->camelize($value);$name = str_replace('.','Controller.',ucfirst($name));fwrite($myfile, "Route::group(['prefix' => '".str_before($value,'.php')."'], function () {");$file = file_get_contents($dir.$value);$pattern ='/['act']s+==s+'(.*?)'|functions+(.*?)n{/';preg_match_all($pattern,$file,$match);$sameFun = [];foreach ($match as $key =>$v){if($key == 0){continue;}foreach ($v as $i){if(!empty($i)){if(in_array($i,$sameFun)){
// fwrite($myfile, "rtpublic function new_".$i."t{rt}r");fwrite($myfile, "rtRoute::get('/new_".str_before($i,'(')."', '".str_before($name,'.php')."@new_".str_before($i,'(')."');");}else{fwrite($myfile, "rtRoute::get('/".str_before($i,'(')."', '".str_before($name,'.php')."@".str_before($i,'(')."');");}$sameFun[] = str_before($i,'(');}}}fwrite($myfile, "r});r");}fclose($myfile);}
本文发布于:2024-02-04 21:49:43,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170717190059914.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |