當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。