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


PHP Sapi::sendResponse方法代码示例

本文整理汇总了PHP中Sabre\HTTP\Sapi::sendResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP Sapi::sendResponse方法的具体用法?PHP Sapi::sendResponse怎么用?PHP Sapi::sendResponse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sabre\HTTP\Sapi的用法示例。


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

示例1: authenticateHttpBasic

 /**
  * @static
  * @throws \Exception
  * @return User
  */
 public static function authenticateHttpBasic()
 {
     // we're using Sabre\HTTP for basic auth
     $request = \Sabre\HTTP\Sapi::getRequest();
     $response = new \Sabre\HTTP\Response();
     $auth = new \Sabre\HTTP\Auth\Basic(Tool::getHostname(), $request, $response);
     $result = $auth->getCredentials();
     if (is_array($result)) {
         list($username, $password) = $result;
         $user = self::authenticatePlaintext($username, $password);
         if ($user) {
             return $user;
         }
     }
     $auth->requireLogin();
     $response->setBody("Authentication required");
     \Logger::error("Authentication Basic (WebDAV) required");
     \Sabre\HTTP\Sapi::sendResponse($response);
     die;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:25,代码来源:Authentication.php

示例2: view

 /**
  * Sends compiled view
  * @param	string	$tpl_name		Name of the template (in "dot" notation)
  * @param	array	$data			Array containing your data; empty by default
  * @param	integer	$status_code	HTTP status code for the response; 200 by default
  */
 function view($tpl_name, $data = [], $status_code = 200)
 {
     $response = new HTTP\Response();
     $response->setStatus($status_code);
     $response->setBody(twig()->render($tpl_name, $data));
     HTTP\Sapi::sendResponse($response);
 }
开发者ID:kblais,项目名称:twigstarter,代码行数:13,代码来源:utils.php

示例3: Response

 * @author Evert Pot (http://evertpot.com/)
 * @license http://sabre.io/license/ Modified BSD License
 */
$userList = ["user1" => "password", "user2" => "password"];
use Sabre\HTTP\Sapi;
use Sabre\HTTP\Response;
use Sabre\HTTP\Auth;
// Find the autoloader
$paths = [__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php', __DIR__ . '/vendor/autoload.php'];
foreach ($paths as $path) {
    if (file_exists($path)) {
        include $path;
        break;
    }
}
$request = Sapi::getRequest();
$response = new Response();
$basicAuth = new Auth\Basic("Locked down area", $request, $response);
if (!($userPass = $basicAuth->getCredentials())) {
    // No username or password given
    $basicAuth->requireLogin();
} elseif (!isset($userList[$userPass[0]]) || $userList[$userPass[0]] !== $userPass[1]) {
    // Username or password are incorrect
    $basicAuth->requireLogin();
} else {
    // Success !
    $response->setBody('You are logged in!');
}
// Sending the response
Sapi::sendResponse($response);
开发者ID:sebbie42,项目名称:casebox,代码行数:30,代码来源:basicauth.php

示例4: switch

        $r->addRoute($route[0], $route[1], $route[2]);
    }
};
$req = $request();
$dispatcher = \FastRoute\simpleDispatcher($routeDefinitionCallback);
$routeInfo = $dispatcher->dispatch($req->getMethod(), '/' . $req->getPath());
switch ($routeInfo[0]) {
    case \FastRoute\Dispatcher::NOT_FOUND:
        $resp = $response();
        $resp->setBody('404 - Page not found');
        $resp->setStatus(404);
        \Sabre\HTTP\Sapi::sendResponse($resp);
        exit;
        break;
    case \FastRoute\Dispatcher::METHOD_NOT_ALLOWED:
        $allowedMethods = $routeInfo[1];
        $resp = $response();
        $resp->setHeader('Allow', $allowedMethods);
        $resp->setBody('405 - Method not allowed');
        $resp->setStatus(405);
        \Sabre\HTTP\Sapi::sendResponse($resp);
        exit;
        break;
    case \FastRoute\Dispatcher::FOUND:
        $className = $routeInfo[1][0];
        $method = $routeInfo[1][1];
        $vars = $routeInfo[2];
        $class = $dic->make($className);
        $class->{$method}($vars);
        break;
}
开发者ID:acidvertigo,项目名称:vela,代码行数:31,代码来源:Bootstrap.php

示例5: showLoginForm

 private function showLoginForm($auth, $response)
 {
     $auth->requireLogin();
     $loginForm = new LoginForm($this->baseuri);
     $response->setBody($loginForm->getBody());
     HTTP\Sapi::sendResponse($response);
 }
开发者ID:krekike,项目名称:sambadav,代码行数:7,代码来源:Auth.php

示例6: send

 public function send()
 {
     \Sabre\HTTP\Sapi::sendResponse($this);
 }
开发者ID:lord2800,项目名称:dynamo,代码行数:4,代码来源:HttpResponse.php

示例7: show

 public function show()
 {
     $this->response->setBody('<h1>Hello World</h1>');
     \Sabre\HTTP\Sapi::sendResponse($this->response);
 }
开发者ID:acidvertigo,项目名称:vela,代码行数:5,代码来源:Homepage.php


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