Skip to content

Instantly share code, notes, and snippets.

@k-holy
Created July 14, 2011 09:44
Show Gist options
  • Save k-holy/1082194 to your computer and use it in GitHub Desktop.
Save k-holy/1082194 to your computer and use it in GitHub Desktop.
Phanda_PathTranslator
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !__gateway\.php$
RewriteRule .* __gateway.php [L]
<?php
Phanda_PathTranslator::getInstance()->initialize()
->setParameterDirectoryName('%VAR%')
->setSearchExtensions('php')
->execute();
/**
* /categories/1/items/2/detail.json へのリクエストの場合
* /categories/%VAR%/items/%VAR% にカレントディレクトリを移動、
* /categories/%VAR%/items/%VAR%/detail.php が読み込まれます。
*/
<?php
$translator = Phanda_PathTranslator::getInstance();
$categoryId = $translator->getParameter(0);
$itemId = $translator->getParameter(1);
$extension = $translator->getExtension();
/**
* /categories/1/items/2/detail.json へのリクエストを処理した結果、
* このファイル(/categories/%VAR%/items/%VAR%/detail.php)が
* 読み込まれたとすると、以下の値がセットされます。
* $categoryId = '1'
* $itemId = '2'
* $extension = 'json'
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment