-
-
Save huglester/4535061 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php // bundles/api_v1/controllers/example.php | |
class Api_V1_Example_Controller extends Controller | |
{ | |
public $restful = True; | |
public function get_hello($name='World') | |
{ | |
return "Hello, {$name}!"; | |
} | |
} | |
// URL: myapp.com/api/v1/en/example/hello/Kindari |
This file contains hidden or 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
<?php // application/routes.php | |
// Url: api/v2/locale/controller/method/params | |
Route::any('api/v(:num)/(:any)/(:any)/(:any)/(:all?)', function($version, $locale, $controller, $method, $rest=''){ | |
Config::set('application.language', $locale); | |
$bundle = "api_v{$version}"; | |
$params = $rest ? explode('/', $rest) : array(); | |
return Controller::call("{$bundle}::{$controller}@{$method}", $params); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment