當前位置: 首頁>>代碼示例>>PHP>>正文


PHP App::any方法代碼示例

本文整理匯總了PHP中Slim\App::any方法的典型用法代碼示例。如果您正苦於以下問題:PHP App::any方法的具體用法?PHP App::any怎麽用?PHP App::any使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Slim\App的用法示例。


在下文中一共展示了App::any方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUpRoutes

 public function setUpRoutes()
 {
     $this->app->get('/', function (Request $request, Response $response, array $args) {
         $response->getBody()->write(file_get_contents(AppConfig::getPathToPublic() . '/app.html'));
     });
     $this->app->any('/api/users/[{id}]', Controller\UsersController::class);
     $this->app->any('/api/sessions/[{api_key}]', Controller\SessionsController::class);
     $this->app->any('/api/trips/[{id}]', Controller\TripsController::class);
     $this->app->any('/api/trips/user/[{user_id}]', Controller\TripsController::class);
 }
開發者ID:JohnUiterwyk,項目名稱:journey-planner,代碼行數:10,代碼來源:JourneyPlanner.php

示例2: testAnyRoute

 public function testAnyRoute()
 {
     $path = '/foo';
     $callable = function ($req, $res) {
         // Do something
     };
     $app = new App();
     $route = $app->any($path, $callable);
     $this->assertInstanceOf('\\Slim\\Route', $route);
     $this->assertAttributeContains('GET', 'methods', $route);
     $this->assertAttributeContains('POST', 'methods', $route);
     $this->assertAttributeContains('PUT', 'methods', $route);
     $this->assertAttributeContains('PATCH', 'methods', $route);
     $this->assertAttributeContains('DELETE', 'methods', $route);
     $this->assertAttributeContains('OPTIONS', 'methods', $route);
 }
開發者ID:hidayat365,項目名稱:phpindonesia.or.id-membership2,代碼行數:16,代碼來源:AppTest.php

示例3: setMap

 /**
  * Sets main dynamic routing params into Slim app
  *
  * @param \Slim\App $app
  *
  * @return void
  */
 public static function setMap($app, $namespace)
 {
     $app->any('/{controller}[/{params:.*}]', function ($request, $response, $args) use($app, $namespace) {
         $contDI = $app->getContainer();
         // Get dependencies.
         // Get called method
         $method = strtolower($request->getMethod());
         // Get config namespace if necessary
         $calledController = $namespace . '\\' . $args['controller'];
         $controller = new $calledController();
         if (is_a($controller, "\\mbarquin\\SlimDR\\ControllerInterface") === false) {
             throw new \Exception('Controller must implement \\mbarquin\\SlimDR\\ControllerInterface');
         }
         $funcArgs = \mbarquin\SlimDR\Factory::getArgs($request, $response, $args, $contDI, $controller, $method);
         call_user_func_array(array($controller, $method), $funcArgs);
     });
 }
開發者ID:mbarquin,項目名稱:slim-dynamic-routing,代碼行數:24,代碼來源:Factory.php


注:本文中的Slim\App::any方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。