Last active
October 18, 2017 04:19
-
-
Save Go-Noji/3706dfc7c9c86e5d667b88666222f1c2 to your computer and use it in GitHub Desktop.
Codeigniterでサブディレクトリに配置したコントローラを直下に置いたかのようにルーティングする ref: http://qiita.com/Go-Noji/items/98af035a25ac2d9cf218
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//controllers直下として振舞わせるサブディレクトリ名 | |
$main_directory = 'front'; | |
//サブディレクトリにある.php拡張子が付いたファイルを探してマッピング | |
$paths = scandir(APPPATH.'controllers/'.$main_directory); | |
foreach ($paths as $path) | |
{ | |
$info = pathinfo($path); | |
if ($info['extension'] === 'php') | |
{ | |
$name = lcfirst($info['filename']); | |
$route[$name.'(.*)'] = $main_directory.'/'.$name.'$1'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment