当前位置: 首页>>代码示例>>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;未经允许,请勿转载。