Skip to content

Instantly share code, notes, and snippets.

@Go-Noji
Last active October 18, 2017 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Go-Noji/3706dfc7c9c86e5d667b88666222f1c2 to your computer and use it in GitHub Desktop.
Save Go-Noji/3706dfc7c9c86e5d667b88666222f1c2 to your computer and use it in GitHub Desktop.
Codeigniterでサブディレクトリに配置したコントローラを直下に置いたかのようにルーティングする ref: http://qiita.com/Go-Noji/items/98af035a25ac2d9cf218
//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