当前位置: 首页>>代码示例>>PHP>>正文


PHP Slim\App类代码示例

本文整理汇总了PHP中Slim\App的典型用法代码示例。如果您正苦于以下问题:PHP App类的具体用法?PHP App怎么用?PHP App使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了App类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: runApp

 /**
  * Process the application given a request method and URI
  *
  * @param string $requestMethod the request method (e.g. GET, POST, etc.)
  * @param string $requestUri the request URI
  * @param array|object|null $requestData the request data
  * @return \Slim\Http\Response
  */
 public function runApp($requestMethod, $requestUri, $requestData = null)
 {
     // Create a mock environment for testing with
     $environment = Environment::mock(['REQUEST_METHOD' => $requestMethod, 'REQUEST_URI' => $requestUri]);
     // Set up a request object based on the environment
     $request = Request::createFromEnvironment($environment);
     // Add request data, if it exists
     if (isset($requestData)) {
         $request = $request->withParsedBody($requestData);
     }
     // Set up a response object
     $response = new Response();
     // Use the application settings
     $settings = (require __DIR__ . '/../../src/settings.php');
     // Instantiate the application
     $app = new App($settings);
     // Set up dependencies
     require __DIR__ . '/../../src/dependencies.php';
     // Register middleware
     if ($this->withMiddleware) {
         require __DIR__ . '/../../src/middleware.php';
     }
     // Register routes
     require __DIR__ . '/../../src/routes.php';
     // Process the application
     $response = $app->process($request, $response);
     // Return the response
     return $response;
 }
开发者ID:COCAFoundation,项目名称:coca_help,代码行数:37,代码来源:BaseTestCase.php

示例2: getSlimRouteFromApplication

 /**
  * @param SlimApp $slimApp
  * @return SlimRoute
  */
 private function getSlimRouteFromApplication(SlimApp $slimApp)
 {
     $slimRouter = $slimApp->getContainer()->get('router');
     /** @var $slimRouter SlimRouter */
     $slimRoutes = $slimRouter->getRoutes();
     return $slimRoutes['route0'];
 }
开发者ID:postalservice14,项目名称:sainsburys-http-service,代码行数:11,代码来源:RoutingComponentTest.php

示例3: load

 public function load(array $settings = [])
 {
     $service = new SlimApp($settings);
     $provider = new ServiceProvider();
     $provider->register($service->getContainer());
     $this->setService($service);
 }
开发者ID:iceberg2,项目名称:service-slim,代码行数:7,代码来源:Manager.php

示例4: hasRoutesConfigured

 private function hasRoutesConfigured() : bool
 {
     $slimContainer = $this->slimApp->getContainer();
     $slimRouter = $slimContainer->get('router');
     /** @var $slimRouter SlimRouter */
     return (bool) count($slimRouter->getRoutes());
 }
开发者ID:postalservice14,项目名称:sainsburys-http-service,代码行数:7,代码来源:SlimAppAdapter.php

示例5: __construct

 public function __construct(App $app)
 {
     $app->group('/periodos', function () {
         $this->get('/actual', RetriveActualAction::class);
         $this->get('/{anio}', RetrivePeriodosDelAnio::class);
     });
 }
开发者ID:lacteosdelcesar,项目名称:s3-untitledApi-K,代码行数:7,代码来源:Routes.php

示例6: register

 public static function register(App $app, $config)
 {
     $app->getContainer()['imagecache'] = function () use($config) {
         return new Manager($config);
     };
     $app->get("/{$config['path_web']}/{$config['path_cache']}/{preset}/{file:.*}", (new ImagecacheRegister())->request())->setName('onigoetz.imagecache');
 }
开发者ID:onigoetz,项目名称:imagecache,代码行数:7,代码来源:ImagecacheRegister.php

示例7: initModules

 /**
  * Load the module. This will run for all modules, use for routes mainly
  * @param string $moduleName Module name
  */
 public function initModules(App $app)
 {
     $container = $app->getContainer();
     $this->initDependencies($container);
     $this->initMiddleware($app);
     $this->initRoutes($app);
 }
开发者ID:martynbiz,项目名称:slim-module,代码行数:11,代码来源:Initializer.php

示例8: setUp

 public function setUp()
 {
     $app = new App();
     $kernel = new Kernel($app, $app->getContainer());
     $kernel->registerServices();
     $kernel->registerRoutes();
     $this->app = $app;
 }
开发者ID:raistlfiren,项目名称:slim-skeleton,代码行数:8,代码来源:AbstractTestFunctional.php

示例9: __construct

 function __construct(\Slim\App $app, RequestInterface $request, ResponseInterface $response, $args = false)
 {
     $this->app = $app;
     $this->container = $app->getContainer();
     $this->request = $request;
     $this->response = $response;
     $this->args = $args;
 }
开发者ID:skyling,项目名称:slim-MVC,代码行数:8,代码来源:Controller.php

示例10: __construct

 public function __construct(\Slim\App $app)
 {
     $this->app = $app;
     $this->view = $app->getContainer()->get('view');
     $this->pdo = $app->getContainer()->get('pdo');
     if (!$this->pdo instanceof PDO) {
         throw new \RuntimeException(sprintf('%s requires a PDO instance, app did not contain "PDO" key', __CLASS__));
     }
 }
开发者ID:erdemece,项目名称:news-website,代码行数:9,代码来源:SiteSettings.php

示例11: init

 public function init(\Slim\App $app)
 {
     $app->group('/categories', function () {
         $this->get('', '\\Controllers\\Categories:index');
         $this->map(['GET', 'POST'], '/created', '\\Controllers\\Categories:created');
         $this->map(['GET', 'POST'], '/edit/{id}', '\\Controllers\\Categories:edit');
         $this->map(['GET', 'POST'], '/delete/{id}', '\\Controllers\\Categories:delete');
     });
 }
开发者ID:i4j5,项目名称:burgermaniya,代码行数:9,代码来源:Categories.php

示例12: Route

 public static function Route()
 {
     $app = new App();
     // Reminder: the request is processed from the bottom up,
     // the response is processed from the top down.
     $app->add(SlimMiddleware::class);
     $app->add(Grover::class);
     $app->run();
 }
开发者ID:PaulJulio,项目名称:php-slim-echo-grover,代码行数:9,代码来源:Router.php

示例13: runApp

 /**
  * @param String $method
  * @param Uri   $uri
  * @param array $post
  */
 protected function runApp($method, $uri, $post = [])
 {
     $this->buildApp();
     $this->buildRequest($method, $uri, $post);
     $this->app->getContainer()['request'] = $this->request;
     $this->app->getContainer()['response'] = $this->response;
     $this->response = $this->app->run(true);
     $this->response->getBody()->rewind();
     $this->html = $this->response->getBody()->getContents();
 }
开发者ID:asaokamei,项目名称:slim-tuum,代码行数:15,代码来源:UnitTestsAppTrait.php

示例14: register

 public function register(App &$app)
 {
     $app->get('/version', function (Request $request, Response $response) {
         $response->getBody()->write(json_encode("v1.0.0"));
         return $response->withHeader('Access-Control-Allow-Origin', '*');
     });
     $app->options('/version', function (Request $request, Response $response, $args) use(&$self) {
         return $response->withHeader('Access-Control-Allow-Origin', '*')->withHeader('Access-Control-Allow-Headers', 'Content-Type');
     });
 }
开发者ID:mroswald,项目名称:invme,代码行数:10,代码来源:Version.php

示例15: newApp

 public function newApp()
 {
     // config
     $debug = false;
     if (defined("DEBUG")) {
         $debug = true;
     }
     // Make a Slim App
     $app = new App(['settings' => ['debug' => $debug, 'whoops.editor' => 'sublime']]);
     $app->add(new WhoopsMiddleware());
     $this->app = $app;
 }
开发者ID:SharkIng,项目名称:ss-panel,代码行数:12,代码来源:Slim.php


注:本文中的Slim\App类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。